Wednesday

Input/Output


In C, return type of getchar(), fgetc() and getc() is int (not char). So it is recommended to assign the returned values of these functions to an integer type variable.
  char ch;  /* May cause problems */  
  while ((ch = getchar()) != EOF) 
  {
     putchar(ch);
  }
Here is a version that uses integer to compare the value of getchar().
  int in;  
  while ((in = getchar()) != EOF) 
  {
     putchar(in);
  }

Kindly Bookmark this Post using your favorite Bookmarking service:
Technorati Digg This Stumble Stumble Facebook Twitter
YOUR ADSENSE CODE GOES HERE

0 comments:

Post a Comment

Dont Forget for Commets

 

| C programing tutorials © 2009. All Rights Reserved | Template Style by My Blogger Tricks .com | Design by Brian Gardner | Back To Top |