我有這種很簡單的C,僅僅必須回聲值x
數組內,令人驚訝的代碼的可變的內部輸出打印值,它也呼應陣列y
內的值...C:未呼應
#include <iostream.h>
#include <conio.h>
#include <string.h>
int i;
char x[3]={'a','b','c'},
y[3][2]={
{'a','A'},
{'b','B'},
{'c','C'}};
void main(){
clrscr();
while(i<strlen(x)) cout << x[i++] << endl;
getch();
}
輸出:
a
b
c
a
A
b
B
c
C
很明顯,第3個字符是那些我真的打算呼應......
但如何從陣列y
那些以下字符?
'x'和'y'都不以null結尾。使用'strlen'是未定義的行爲。 – 0x499602D2
哦,我看到'strlen'適用於以空字符結尾的數組,這是字符串... – 707