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;
}
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;
}