im trying to concatsomm strings and call a expext script on my server, but im a .net programer and new to c and pointers so keep messing up… what am i doing wrong here?
or a better question wold be how should i really do this?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
//location of expect script that ssh and gets info on other server
char str0[] = "./home/systemio/Develop/getfile ";
char* strP = argv[1];
char str1 = (char)*strP;
char str2[] = " > file.txt";
strcat(str0,str1);
strcat(str0,str2);
printf("%s\n", str0);
system(str0);
printf("Done!!!!\n");
return 0;
}
You can allocate a buffer for the system command to ensure there is definitely enough space to construct the full command: