Solved

STDIN

Posted on 2003-11-02
2
408 Views
Last Modified: 2010-04-15
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 Comments
 
LVL 6

Accepted Solution

by:
Ajar earned 50 total points
ID: 9668870
The solution is

#include <stdio.h>

// and instead of    STDIN  use stdin

stdin is linked to the keyboard  readily


0
 

Author Comment

by:Red_Dash_Dave
ID: 10272991
Sorry it took so long to accept your answer.

Thanks for your help :)
Dave
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Statment to match two tables in c# 6 81
Pointer in one class to member in another 6 125
How to programmatically differentiate between C and Java 10 204
Fill Null values 5 28
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

830 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