I'm making a program to be opened this way:
How can i read the in.file using the stdin parameter?Quote:
$ proj1 <in.file> out.file
How can i get the out.file name to create that output file?
Thanks!
Printable View
I'm making a program to be opened this way:
How can i read the in.file using the stdin parameter?Quote:
$ proj1 <in.file> out.file
How can i get the out.file name to create that output file?
Thanks!
You don't need to do anything at all.
fgets( buff, sizeof buff, stdin );
will read a line from the file.
printf( "hello world\n" );
would write to the output file.
Redirections are handled by the shell, not your program.
just do it...
So? As I said - just use it. No difference from the fgets approach Salem suggested... Instead of reading lines - read char by charQuote:
but its for college, my teacher says that i need to use getc(stdin) to receive the file, i know that are other ways but that is a must unfortunatly
Code:int c;
while((c=getc(stdin)) != EOF)
{
process char here
}
ok thanks!! ;)