合法的数组定义是( ) 。
A: char a[ ] = {‘s’, ‘t’, ‘r’, ‘i’, ‘n’, ‘g’, 0};
B: char s = "string";
C: char a[ ] = {‘s’, ‘t’, ‘r’, ‘i’, ‘n’, ‘g’, ‘\0’};
char a[] = "string";
A: char a[ ] = {‘s’, ‘t’, ‘r’, ‘i’, ‘n’, ‘g’, 0};
B: char s = "string";
C: char a[ ] = {‘s’, ‘t’, ‘r’, ‘i’, ‘n’, ‘g’, ‘\0’};
char a[] = "string";
举一反三
- 在以下字符串String的赋值运算中,错误的是( )。? char str[]= { 'S' ,'t', 'r' ,'i','n', 'g',0};|char str[10]= { 'S' ,'t', 'r' ,'i','n', 'g','\0'};|char str[6]= { 'S' ,'t', 'r' ,'i','n', 'g'};|char str[10]= "String";
- 下面字符数组初始化语句正确且与语句char c[]="string";等价的是( ) 。 A: char c[]={'s','t','r’,'i’,'n','g'}; B: char c[]={'s','t','r’,'i’,'n','g','\0'}; C: char c[]={'string'}; D: char c[]='string';
- 下面对字符数组不正确的初始化方式是________。 A: char ch[]="string"; B: char ch[7]={'s', 't', 'r', 'i', 'n', 'g'}; C: char ch[10]; ch="string"; D: char ch[7]={'s', 't', 'r', 'i', 'n', 'g', '\0'};
- 执行下面的初始化语句,( )保存的不是字符串。 A: char str[10]= { 'S' ,'t', 'r' ,'i','n', 'g','\0'}; B: char str[10]= "String"; C: char str[6]= { 'S' ,'t', 'r' ,'i','n', 'g'}; D: char str[]= { 'S' ,'t', 'r' ,'i','n', 'g',0};
- 下列初始化语句中,正确且与语句char c[ ]="string";等价的是________. A: char c[ ]={'s','t','r','i','n','g'}; B: char c[ ]='string'; C: char c[7]={'s','t','r','i','n','g','\0'}; D: char c[7]={'string'};