Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-08-2004, 04:51 AM   #1
LQ Newbie
Registered: May 2004
Distribution: Slackware 9.1
Posts: 8

Rep: Reputation: 0
simple C program problem

I'm beginning to program in C, and i'm reading K&R.

At start I Followed the book, but then i've done other very simple maths programs that can be helpful...

Now, the problem is that I wanted to come back on K&R to learn more, but when i try to execute one of the programs written in the book, it just doesn't work. I think its a problem with getchar()...but i let you judge by yourself and I hope you have a solution for that problem :-)

#include <stdio.h>

main ()


long c;

while ( getchar() != EOF )
printf ("%ld\n", c);

Thank you
Old 05-08-2004, 05:08 AM   #2
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
this program works, but probably not the way you thought it would work.

boxx> echo -n "ABCDE" | ./myprog
Old 05-08-2004, 05:42 AM   #3
LQ Newbie
Registered: May 2004
Distribution: Slackware 9.1
Posts: 8

Original Poster
Rep: Reputation: 0
thank you very much you saved my young-programmer-life



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SDL problem... simple program. RHLinuxGUY Programming 1 07-22-2005 06:04 PM
simple C program problem speel Programming 14 02-27-2005 05:08 PM
simple c program liguorir Linux - Software 4 05-29-2004 06:22 AM
simple program big problem antken Programming 3 09-15-2002 10:39 AM
Help with the following simple C program ..... purpleburple Programming 5 09-13-2002 10:52 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:16 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration