Solved

STDIN

Posted on 2003-11-02
2
405 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays 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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now