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++; } ____
}[/i][/i][/i]
A: return;
B: string1[i - 1] = '\0';
C: string1[i] = '\0';
D: string1[i + 1] = '\0';
}[/i][/i][/i]
A: return;
B: string1[i - 1] = '\0';
C: string1[i] = '\0';
D: string1[i + 1] = '\0';
举一反三
- 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) ;
- 下列语句正确的是( ) 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";
- 下述()语句能够正确地生成5个空字符串。 A: String a[]=new String[5];for(int i=0;i<;5;a[i++]=“”); B: String a[5]; C: String [5] a; D: String [] a=new String[5];for (int i=0;i<;5;a[i++]=null);
- 下面哪个语句能够正确地生成5个空字符串?( ) A: String a[]=new String[5]; for(int i=0;i<;5;a[i++]=""); B: String a[5]; C: String []a=new String[5]; for( int i=0;i<;5;a[i++]=null); D: String[5]a;
- 下面程序代码运行结果为( )。 import java.awt.*; public class Test { public static void main (String args[]) { String s1="a+b+c"; String s2="+"; int i=s1.lastIndexOf (s2); System.out.println(i); } } A: 0 B: 1 C: 2 D: 3