Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用'停止While循环\0';_C++_Arrays_While Loop_Char - Fatal编程技术网

C++ 使用'停止While循环\0';

C++ 使用'停止While循环\0';,c++,arrays,while-loop,char,C++,Arrays,While Loop,Char,当字符数组到达“\0”时,我无法停止while循环。我知道这永远是任何字符数组的最后一个元素,所以我不明白为什么下面的代码永远不会结束循环。任何帮助都将不胜感激 char randomString[] = "testSTRING"; int counter = 0; while (randomString[counter] != '\0') cout << "test"; charrandomstring[]=“testSTRING”; int计数器=0; while(随

当字符数组到达“\0”时,我无法停止while循环。我知道这永远是任何字符数组的最后一个元素,所以我不明白为什么下面的代码永远不会结束循环。任何帮助都将不胜感激

char randomString[] = "testSTRING";

int counter = 0;
while (randomString[counter] != '\0')
    cout << "test";
charrandomstring[]=“testSTRING”;
int计数器=0;
while(随机字符串[计数器]!='\0')
试试这个:

char randomString[] = "testSTRING";

int counter = 0;

while (randomString[counter++] != '\0')`

    cout << "test";
charrandomstring[]=“testSTRING”;
int计数器=0;
while(随机字符串[counter++]!='\0')`

难道你的
计数器实际上什么都不算吗。它总是零。这真让人尴尬。。。非常感谢你。