Give the output of the following program main() {char *s; s="hot java"; strcpy(s,"solarrs java") }

Showing Answers 1 - 3 of 3 Answers

olaf

  • Nov 16th, 2006
 

line #3: Incorrect: Only way to assign a value to a char * is using strcpy; except during the declaration statement.char * s = "hot java"; // CORRECTchar *s;s = "hot java"; // INCORRECTif the CORRECT statement is taken, 'strcpy (s, "solaris java");' would probably crash because the space allocated for s is only 9 bytes and 13 bytes cannot be accomodated in s (unless you do some kind of realloc)./Olaf

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions