Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

STDIN

Posted on 2003-11-02
3
Medium Priority
?
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 200 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 101

Expert Comment

by:mlmcc
ID: 9671022
Glad I could help

mlmcc
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

618 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