This code works:
Code:
/*
Compiled under Turbo C 2.01
DO NOT COMPILE WITH WINDOWS
GCC! I haven't tried any
other compilers.
*/
#include <stdio.h> /* For output/input */
#include <stdlib.h> /* For system() */
#include <string.h> /* For strcmp() */
#include <unistd.h> /* For getcwd() */
int main()
{
/* The users' command */
char input[16];
/* Path variables( getcwd() ) */
char *ppath; /* Pointer to PATH */
int ipath; /* Size of PATH */
/* Special Command Strings */
char root[3] = "\\\n";
char quit[6] = "quit\n";
char ls[4] = "ls\n";
for(;;)
{
getcwd(ppath,ipath); /* Get the current directory */
printf("%s>",ppath); /* mimic DOS prompt */
fgets(input,16,stdin); /* Get the input */
/* Check for "special" commands
(which are really simple DOS commands)
If not, then let DOS execute the
command.*/
if((strcmp(input,root) == 0) || (strcmp(input,quit) == 0) || (strcmp(input,ls) == 0))
{
if(strcmp(input,root) == 0)
{
system("cd \\");
}
if(strcmp(input,quit) == 0)
{
return 0;
}
if(strcmp(input,ls) == 0)
{
system("dir");
}
}
else
{
system(input);
}
}
}
But if I add
Code:
/* Welcome */
printf("Welcome to DOS/ENHANCE! ");
after the start of int main, my compiler gives my expression errors. I'm using Turbo C 2.01. I don't see anything wrong with my new code. Is this just a compiler problem?