LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 07-03-2002, 06:15 PM   #1
purpleburple
Member
 
Registered: Jun 2002
Location: USA
Distribution: Slackware8.1
Posts: 332

Rep: Reputation: 30
putchar and putc are not working ....


Hi. I'm using Redhat 7.2 and emacs that came with it. Learning C. I did the following little program from a C book.

#include <stdio.h>

int main(void)
{

putchar(65);

return 0;
}


my output after compiling and running is just blank after the program runs.
It's the same with the following

#include <stdio.h>

int main(void)
{

int ch;
ch = 65;


printf("The character that has the numerical value of 65 is:\n");

putc(ch, stdout);
return 0;
}

i compile putc.c with > gcc -o putc putc.c

then I run it at bash prompt with ./putc
and I get a blank line as output
 
Old 07-03-2002, 09:34 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Do you see the output from the printf?

Try assigning the return value from putc and either print it out with printf, if it works, or test it in an if condition against EOF.

Code:
   iReturnCode = putc( ch, stdio );
   if ( iReturnCode == EOF )
      exit ( -1 );
   else
      exit ( 1 );
 
Old 07-04-2002, 10:28 AM   #3
purpleburple
Member
 
Registered: Jun 2002
Location: USA
Distribution: Slackware8.1
Posts: 332

Original Poster
Rep: Reputation: 30
yes I do see the output from printf but then it's blank after that on the standard output
 
Old 07-04-2002, 10:30 AM   #4
purpleburple
Member
 
Registered: Jun 2002
Location: USA
Distribution: Slackware8.1
Posts: 332

Original Poster
Rep: Reputation: 30
On the program with just the putchar() function I see absolutely nothing on standard output
 
Old 07-04-2002, 03:28 PM   #5
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You should send '\n' to the output after your character.
 
  


Reply



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
putc problem - LED flashing vasanthraghavan Programming 3 04-19-2004 03:46 PM
Noob question about putchar and getchar zombi3 Programming 2 12-20-2003 04:38 PM
cannot download files in mozilla -save dialog not working, galeon not working cmisip Linux - General 0 08-03-2003 03:25 PM
putc and fputc - and other confusion Linh Programming 8 07-21-2003 06:54 AM
Simple question about putchar ... in C purpleburple Programming 1 06-30-2002 04:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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