J
JC
hi,
i want to combine two string together.. and put in to another string. how
can i do . i try myself.. with the follow code. but seem can't get the
result i want.. i want to get the result with "c is abcd" .
#include <stdio.h>
#include <string.h>
void main() {
char a[2]="ab";
char b[2]="cd";
char c[4]=" \0";
strcpy(c,a);
strcat(c,b);
printf("a is %s\n",a);
printf("b is %s\n",b);
printf("c is %s\n",c);
}
i only get this result
a is b?
b is b?
c is ab?b?
what problem to my coding? anything wrong?
please help!!.
Thanks
JC
ps. if i use strcpy(c,"ab"); and strcat(c,"cd"); i can get the result.."c is
abcd"
i want to combine two string together.. and put in to another string. how
can i do . i try myself.. with the follow code. but seem can't get the
result i want.. i want to get the result with "c is abcd" .
#include <stdio.h>
#include <string.h>
void main() {
char a[2]="ab";
char b[2]="cd";
char c[4]=" \0";
strcpy(c,a);
strcat(c,b);
printf("a is %s\n",a);
printf("b is %s\n",b);
printf("c is %s\n",c);
}
i only get this result
a is b?
b is b?
c is ab?b?
what problem to my coding? anything wrong?
please help!!.
Thanks
JC
ps. if i use strcpy(c,"ab"); and strcat(c,"cd"); i can get the result.."c is
abcd"