如果有定义语句char str1[10],str2[10]={"books"};则能将字符串"books"赋给数组str1的正确语句是( )。
举一反三
- 【单选题】假设有如下变量定义“char str1[8],str2[8]="good";,则不能实现将字符数组str2赋值给str1的语句是() A. str1=str2; B. strcpy(str1,str2); C. strncpy(str1,str2,6); D. memcpy(str1,str2,5);
- 以下涉及字符串数组、字符指针的程序段中,没有编译错误的是()。 A: char* str, name[1]; str = "Hello"; B: char* str, name[1]; name = "Hello"; C: char str1[10] = "ex1.c", str2[6]; str2 = str1; D: char head_line[]; head_line = "\\0";
- 以下涉及字符串数组、字符指针的程序段,不会产生编译错误的是______。 A: char* str, name[10]; str = "Hello World"; B: char* str, name[10]; name = "Hello World"; C: char str1[10] = "prog.c", str2[10]; str2 = str1; D: char head_line[]; head_line = "=============";
- 以下涉及字符串数组、字符指针的程序片段,没有编译错误的是( )。 A: char line[]; line="============="; B: char* name[10], *str; name = "Hello World"; C: char str1[10],str2[10]= "prog.c"; str1 = str2; D: char name[10],*str = "Hello World";
- 下列关于字符串使用正确的是() A: char str[10]; str="Hello"; B: char *str; strcpy(str,"Hello"); C: char *str1,str[10]="Hello"; strcpy(str,str1); D: char *str; str="Hello";