Question for strcpy and pointer

  • Thread starter Thread starter Linda8888
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 941 views
Linda8888
Messages
7
Reaction score
1
Summary:: Question: In the blank space below, write a new version of the first line of this code segment such that the strcpy succeeds. Use only stack memory and try not to waste memory.

how can I change the first line of the code?

Code:
char *s1;       // change this line
char *s2 = "good luck";
strcpy(s1, s2); // I must succeed
 
Physics news on Phys.org