code:
char *command=(char*)malloc(1024*sizeof(char));
char *tmp=(char*)malloc(10*sizeof(char));
memset(tmp,0,10);
tmp = strcat(tmp,"123456789");
.
.
.
fprintf(stdout,"\nbefore %s",tmp);
command=strcat(strcat(strcat(var1,var2),var3),var4);
fprintf(stdout,"\n%s",command);
fprintf(stdout,"\nafter %s",tmp);
problem:
tmp points that string numbers, and is never used till the other part of the code, the first printf prints correct the string, the variable command is also good to, bue the second time showing tmp it shows part of the command string, why is this???
char *command=(char*)malloc(1024*sizeof(char));
char *tmp=(char*)malloc(10*sizeof(char));
memset(tmp,0,10);
tmp = strcat(tmp,"123456789");
.
.
.
fprintf(stdout,"\nbefore %s",tmp);
command=strcat(strcat(strcat(var1,var2),var3),var4);
fprintf(stdout,"\n%s",command);
fprintf(stdout,"\nafter %s",tmp);
problem:
tmp points that string numbers, and is never used till the other part of the code, the first printf prints correct the string, the variable command is also good to, bue the second time showing tmp it shows part of the command string, why is this???