instant output

This is a discussion on instant output within the C Programming forums, part of the General Programming Boards category; I have two questions regarding program below. 1) Since ch is just an integer, where do all characters I enter ...

  1. #1
    Registered User PutoAmo's Avatar
    Join Date
    Mar 2002
    Posts
    72

    instant output

    I have two questions regarding program below.
    1) Since ch is just an integer, where do all characters I enter after first one get saved? Let's say I enter abcdefg. 'a' will be stored at ch location. 'b' will then overwrite 'a', 'c' overwrites 'b', and so on. Where are those characters saved in order to not getting overwritten?

    2)How can I modify this program so characters show on the screen as soon as I enter them?

    Code:
    #include <stdio.h>
    
    int main (void)
    {
     int ch;
    
     while ((ch = getchar ()) != EOF)
      putchar (ch);
    
     return 0;
    }
    Thx !

  2. #2
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    1) characters are not saved

    2) you already did it ur self unless u mean somethin different or i misinterpreted your qs ...

  3. #3
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    
    int main (void)
    {
     int ch;
    
     while ((ch = getch()) != EOF)
      putchar (ch);
    
     return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code output...
    By roaan in forum C Programming
    Replies: 6
    Last Post: 07-03-2009, 02:22 AM
  2. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 02:08 PM
  3. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 02:29 PM
  4. Replies: 4
    Last Post: 11-30-2005, 03:44 PM
  5. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21