strcpy function

Hello,

i cannot figure out how can we use the strcpy() function instead of the code below:

1
2
3
4
5
   char useful[5];
   
   int i=0;
   for(; i<4; i++)
        useful[i] = temp[i]; //char temp[200]; 


Thank you very much.
Use strncpy instead, if the source buffer can be larger than the destination.

 
strncpy( useful, temp, sizeof( useful ) );
Thank you very much JSMITH .
Topic archived. No new replies allowed.