So I try "\-126" and get a compile error. Any other ideas?
-126 is 82 hex -- try \x82
So I try "\-126" and get a compile error. Any other ideas?
-126 is 82 hex -- try \x82
If you wish, your program can assume that if there was nothing on the command line, redirection is being used. In that case, instead of using the fopen(), simply assign stdin to your stream:
FILE *stream;
if (argc < 2)
{
stream = stdin;
}
else
{
stream = fopen(argv[i],"r");
if (stream==NULL)
...
}
This allows your program to take a file
> prog file.name
redirected file
>prog <file.name
or from the keyboard
>prog