I'm preparing to make a very simple linux shell in c (one that will just run one program with any required arguments and perhaps later might search for the program in a path variable if its not found in the working directory).
Anyway I thought since its currently well above my skill level in C I would learn to play with loops since thats pretty much what the shell will be doing wont it?
#include <stdio.h>
#define SENTINEL -1 // to be implemented later.
int main()
{
char v[256];
char command;
do
{
fgets(v, 256, stdin);
system(v);
} while (fgets(v, 256, stdin) != NULL);
}
my intention is that if the user enters just '\n' without anything else or 'sentinel' is typed (-1) then the code will no longer loop otherwise it will indefinently run commands for the user I've tried heaps but cant seem to make anything work..