It was required to remove empty lines using C program . Either to be
run like :
./nnoemptylines < textfile
or accept location of the file as a full path from the user dialog to
accept .
The spec is almost impossible.
../noemptylines < textfile redirects textfile to stdin. So if the
program is invoked thusly, it needs to read in lines from stdin, check
if they are non-blank, and then echo them to stdout. So far so good.
The problem is that
../noemptyfiles
should set up a dialogue with the user. So you want to print something
like
"Hello user, please enter the name of the file from which ypu wish to
remove blanks"
The user enters
textfile
"Thank you, do you wish to overwrite the file?"
etc
The problem is that there's no easy way to know whether stdin is
directed from a file or coming from a keyboard. That's deliberate. We
don't generally want programs making this distinction. I'm sure that
on your particular system there will besome operating call, probably
poorly documented, which you can make. But it's inappropriate and bad
practice to use it for a ultility program like a deblanker.
I'd throw the spec back, with this objection.