Hi.
I'm very new to the C language, but I have written programs in perl and shell programming. I want to learn C so I started rewriting my shell program in it. I'm using the same structure as my shell program and up to this point I've gotten it to compile and run correctly, Ending up with the same result as it's shell equivalent.
What I bumped my head on is this
//interface variables
char lanint[7] = "";
char wanint[7] = "";
//show user systems interfaces
system("ifconfig -a");
//ask user for LAN interface
printf("What interface do you want as your LAN?\n");
scanf("%s", &lanint);
//ask user for WAN interface
printf("What interface do you want as your WAN?\n");
scanf("%s", &wanint);
printf("Writing interface configuration\n");
//open hostname.if files
lanfi = fopen("/etc/hostname.lanint" "w+");
fclose(lanfi);
wanfi = fopen("/etc/hostname.wanint", "w+");
fclose(wanfi);
I need the variables lanint and wanint to be used as a suffix to the fopen filename.
eg fopen("/etc/hostname.em0", "w+");
but the suffix is just whatever the user types instead of hardcoding it. I'll end up putting valid configuration in those files after I get the name correct.
If this is completely wrong I totally understand. I'm not the best programmer nor in the profession of such. But regardless I enjoy programming very much.