what is a good way to do this?
what is a good way to do this?
Why not strcpy?
This works
Code:char a[]="Sorensen"; char b[256]; int i=0; while(b[i++]=a[i]) ;
i cant use array notation, pointers only! this is totally getting me! helpOriginally posted by Sorensen
Why not strcpy?
This works
Code:char a[]="Sorensen"; char b[256]; int i=0; while(b[i++]=a[i]) ;
Ok -
Code:char* a="Sorensen"; char b[256]; char* c=b; while(*c++=*a++) ;
Mmmm would you need to add a line which places a '\0' at the end of the new string?
>Mmmm would you need to add a line which places a '\0' at the end of the new string?
No, because the '\0' will be assigned and then the while loop stops because *c contains '\0'. It's checking the target string not the source.
Oh yeah, I see. check the target, thats an easier way to do it