Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String functions strcpy with backslashes

Status
Not open for further replies.

texto

Programmer
Dec 11, 2007
1
0
0
GB
Not sure if this is an easy one but how do I copy an character array with backslashes to another? Strcpy behaves very strange.

As in the example - ascstr2 prints all weird chars.



ascstr is \x0

ascstr2 is øF



#include <stdio.h>



int main(){
char ascstr[20];
char ascstr2[20];
char *p;
p=ascstr;

*p++ = '\\';
*p++ = 'x';
*p++ = '0';
*p = '\0';
printf ("\nascstr is %s\n", ascstr);
strcpy(ascstr, ascstr2);
printf ("\nascstr2 is %s\n", ascstr2);
return 0;
}
 
strcpy (destination, source);

ergo

strcpy (ascstr2, ascstr);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top