Question: Please help, those are my Computer science homework problem, Question is below, thank you a lot!! Code: #include #include main() { int i; char s[5],

Please help, those are my Computer science homework problem, Question is below, thank you a lot!!

Code:

Please help, those are my Computer science homework problem, Question is below,

#include

#include

main() {

int i;

char s[5], s1[ ] = "hello", s2[5] = "world"; // s2[5] = "world" incorrect;

for (i = 0; i

printf("%c", s1[ i ]);

printf(" ");

printf("s1 = %s, size = %d ", s1, sizeof s1);

for (i = 0; i

printf("%c", s2[ i ]);

printf(" ");

printf("s2 = %s, size = %d ", s2, sizeof s2); // no end of string

strcpy(s, s1); // unsafe: copy size 6 to 5

printf("s = %s, size = %d ", s, sizeof s);

}

1 . At line 14: strcpy(s, s1); What would happen if the line is replaced by s = s1; ? (A) The problem is fixed and no error at this line. (B) A contextual error will occur at compilation time. (C) The program will crash at run time. (D) No error will be reported, but a semantic error can occur. 2 . At Line 14: Which of the following statement can replace line 14 without generating a contextual or semantic error? (A) s[5] = {'h', 'e', 'l', 'l', 'o}; (B) s = "hello"; (C) s[5] = "hello"; (D) None of them

2 3 I o o o voor A #include #include main() { int i; char s[5], s1[ ] = "hello", s2[5] = "world"; // s2[5] = "world" incorrect; for (i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!