摘要: 假设要编写一个将一系列数字读入到数组的程序,一种方法是使用cin读入。 当程序发现用户输入了错误内容时,应采取3个步骤。 重置cin以接受新的输入。 删除错误输入。 提示用户再输入 注意:程序必须先重置cin,然后才能删除错误输入。 程序实例如下: int golf[Max]; cout << "P 阅读全文
posted @ 2025-06-17 17:02 不会编程的新手 阅读(26) 评论(0) 推荐(0)
摘要: =复制 首先考虑下方代码: char animal[20] = "bear"; char * ps; ps = animal; cout << animal << " at " << (int*)animal << endl; cout << ps << " at " << (int*)ps << 阅读全文
posted @ 2025-06-11 23:36 不会编程的新手 阅读(33) 评论(0) 推荐(0)
摘要: 数组名和指针的区别 通常,使用数组表示法时,C++都执行下面的转换: arrayname[i] becomes *(arrayname + i) 如果使用的是指针,而不是数组名,则C++也将执行同样的转换: pointername[i] becomes *(pointername + i) 因此,在 阅读全文
posted @ 2025-06-11 12:10 不会编程的新手 阅读(76) 评论(0) 推荐(0)