下列语句正确的是( )
A: char string[]; string="china";
B: char string1[],string2[]; string2={"china"}; strcpy(string1,string2);
C: char string1[5],string2[]={"china"}; string1=string2;
D: char string[]="china";
A: char string[]; string="china";
B: char string1[],string2[]; string2={"china"}; strcpy(string1,string2);
C: char string1[5],string2[]={"china"}; string1=string2;
D: char string[]="china";
举一反三
- 对字符串不正确的赋值方式是( )。 A: char *string;string=china; B: char c[]={china}; C: char c[10];c[10]={china}; D: char *string=china;
- Which can replace lines 5 and 6 in the following function ? 1 /* copy string2 to string1 */ 2 void strcopy(char string1[], char string2[]) 3 { 4 int i = 0; 5 while (string1[i] = string2[i]) 6 i++; 7 }[/i][/i] A: while (*string1 = *string2) ; B: while (*string1 = string2) ; C: while (*string1++ = *string2++) ; D: while (*++string1 = *++string2) ;
- 下列【1】【2】【3】【4】注释标注的哪行代码有错误?import java.util.*;public class E {public static void main(String args[]) {Map<;String,String>; map = new HashMap<;String,String>;(); //【1】Set<;Integer>; treeSet = new TreeSet<;Integer>;();//【2】Map<;String,String>; treeMap= new TreeMap<;String,String>;(); //【3】List<;char>; list = new LinkedList<;char>;(); //【4】 A: 【1】 B: 【2】 C: 【3】 D: 【4】
- Complete the following function: /* copy string2 to string1 */ void strcopy(char string1[], char string2[]) { int i = 0; while (string2[i] != '\0') { string1[i] = string2[i]; i++; } ____<br/>}[/i][/i][/i] A: return; B: string1[i - 1] = '\0'; C: string1[i] = '\0'; D: string1[i + 1] = '\0';
- 设有以下变量定义:[br][/br] char str1[]="string",str2[8],*str3,*str4="string"; ( )是正确的 A: strcpy(str1,"China"); B: str2="China"; C: strcpy(*str3,"China"); D: strcpy(str4[0],"China");