FAQ > How do I... (Level 1) > Get a line of text from the user/keyboard (C)
FAQ > How do I... (Level 2) > Run a program from within a program
Put together as something like this.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char path[FILENAME_MAX];
fputs("path? ", stdout);
fflush(stdout);
if (fgets(path, sizeof path, stdin))
{
char command[sizeof path + 30];
char *newline = strchr(path, '\n');
if (newline != NULL)
{
*newline = '\0';
}
sprintf(command, "cpc -B *.cpc -O %s", path);
puts(command); /* to see the created command line */
system(command);
}
return 0;
}
Example:
path? c:\
cpc -B *.cpc -O c:\
Like that?