Solved

STDIN

Posted on 2003-11-02
3
451 Views
Last Modified: 2010-04-16
Hi

I'm a fairly new programmer so go easy on me!! , but my question is this:

I have got to write a driver for a simple text editor  program. One of the pascal files in the program has this code:

if (feof(STDIN))
  *c = ENDFILE;
else
{
  fread(&ch, sizeof(ch), 1, STDIN);

if (feof(STDIN))
  *c = ENDFILE;
else
*c = ord(ch);
}

return *c;

Now, I know there is not much information here but it is supposed to be a text copier of some sort but when I call this file from the driver, STDIN is always NULL and so throws and error. Now I always thought that STDIN was input from the keyboard but I have never actually used it before in this context. This means that I cannot understand how it works... arrrghhh!!
Do I need to link STDIN to the keyboard somehow???
Do I need to link it to a file in this respect (dont know how to do this either)
Just what is going on .. why is it there :-(

the function is called from a C file driver.

Please help. I will do my best to provide any more info if required. But I havnt got a lot.

Thank you
Dave
0
Comment
Question by:Red_Dash_Dave
  • 2
3 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 50 total points
ID: 9665789
I think you need to ask this in the C forum rather than the pascal forum.

mlmcc
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 9670073
Ahh, I was wondering... Strange syntax for a Pascal file... :-) In Pascal it would look more like:

  if eof(Input) then begin
    C := ENDFILE;
  end else begin
    Read(Input, Ch);
    if eof(Input) then begin
      c := ENDFILE;
    end else begin
      c := ord(ch);
    end;
  end;
  Result := c;

But perhaps it's a good idea to check your sources a bit better. You seem to mis them up a bit.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9671022
Glad I could help

mlmcc
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question