Is it possible to do a system call with a string as part your input.
char file[100];
system("vi file");
Is it possible to do a system call with a string as part your input.
char file[100];
system("vi file");
I believe you'd need to concatenate the command into one char array first, then pass that as the arg to system().
Something like
Code:#include <stdio.h> int main(void) { char fn[] = "a.c"; char buffer[1024]; strcpy(buffer, "vi "); // Should really use strncpy and strncat strcat(buffer, fn); system(buffer); return(0); }
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
works like a charm, thanks.