I'm making a program to be opened this way:
How can i read the in.file using the stdin parameter?$ proj1 <in.file> out.file
How can i get the out.file name to create that output file?
Thanks!
This is a discussion on Standard input way? within the C Programming forums, part of the General Programming Boards category; I'm making a program to be opened this way: $ proj1 <in.file> out.file How can i read the in.file using ...
I'm making a program to be opened this way:
How can i read the in.file using the stdin parameter?$ 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.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
just do it...
If I have eight hours for cutting wood, I spend six sharpening my axe.
So? As I said - just use it. No difference from the fgets approach Salem suggested... Instead of reading lines - read char by charbut 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 }
If I have eight hours for cutting wood, I spend six sharpening my axe.
ok thanks!!![]()