若有定义char s1[ ]= “HELLO”, s2[8] = “HELLO1”,s3[80],*s4=s2; 则错误的是
A: strcpy(“s1”, “HELLO”);
B: strcat(s2, “hello2”);
C: strcpy(s3, “hello3”);
D: strcpy(s4, “hello4”);
A: strcpy(“s1”, “HELLO”);
B: strcat(s2, “hello2”);
C: strcpy(s3, “hello3”);
D: strcpy(s4, “hello4”);
A
举一反三
- char s1[ ] = "hello ";char s2[ ] = "tangx ";strcpy(s1, s2);printf("%s\n", s1);以上代码段执行结果为哪个选项? A: hello tangx B: tangx hello C: hello D: tangx
- 中国大学MOOC: 若有定义char s1[ ]= “HELLO”, s2[8] = “HELLO1”,s3[80],*s4=s2; 则错误的是
- s=”hello”,t=”world”,s+=t,则s为________________,s[-1]为________,s[2:5]为_____________,s[::3]为____________,s[-2::-1]为____________________
- 以下要输出“hello,world!”正确的是? A: String s=String.format("%1s%2s","hello","world");System.out.println(s); B: String s=String.format("%1$s,%2$s","hello","world");System.out.println(s); C: String s=String.format("%s,%s","hello","world");System.out.println(s); D: String s=String.format("%1s,%2s","hello","world");System.out.println(s);
- char s[80],*sp="HELLO!";sp=strcpy(s,sp);s[0]='h';puts(sp);运行结果:________
内容
- 0
下列是为字符数组赋字符串的语句组,其中错误是: A: char s[10]; s=”program”; B: char s[]=”program”; C: char s[10]=”Hello!”; D: char s[10];strcpy(s,”hello!”);
- 1
以下程序段的输出结果是 。Char s[ ]=”Hello World!”;Strlwr(s);Printf(“%s”,s); A: hello world! B: HELLO world! C: hello WORLD! D: HELLO WORLD!
- 2
【其它】写出并理解下列语句输出的结果 s = "hello" print(s[0]) print(s[4]) print(s[-1]) print(s[0:3]) print(s[0:4:2]) print(s[:]) print(s[:3]) print(s[::-1]) print(s[1:])
- 3
执行如下代码段输出结果为char s1[10]="nanjing",s2[]="hello";strcpy(s1,s2);puts(s1); A: hello B: hellog C: hello\0g D: hellog
- 4
C语言的以下程序段中,不能正确赋字符串的是() A: chars[10]="hello"; B: chars[10]; s="hello"; C: chart[]="hello",*s=t; D: chars[10]; strcpy(s,"hello");