Thread: What is the character limit of putchar() and getchar()?

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    2

    What is the character limit of putchar() and getchar()?

    I am beginning C. I am assuming that characters have a set memory size for all characters.. mostly anyways. If you do not initialize or allocate specific memory for a program, where are getchar() and putchar() characters stored? What would be the character limit of these? In the Ke3rnighan Ritchie book there is an example program that looks basically like echo, Just wondering what would happen if I typed 1000 or more characters in there?

    sorry if this is something I overlooked

    Diesel

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > Just wondering what would happen if I typed 1000 or more
    > characters in there?

    What do you mean?

    putchar( 1000 );

    Like that? How about you try it and find out. The worse case scenario is you have to reboot...

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Unregistered
    Guest
    getchar(); and putchar(); can only receive one character at a time.

    #include <stdio.h>

    int main()
    {

    char *a_variable_string;
    char the_char;

    a_variable_string="some text";

    getchar(a_variable_string);
    printf("%c", the_char);

    }

    Eg. this program would find the first character in the string a_variable_string and print it to the screen.

    In this case the value is "S"

    if called again it would print "o"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getchar and putchar
    By BEN10 in forum C Programming
    Replies: 4
    Last Post: 03-11-2009, 10:29 PM
  2. Can someone try getchar() please?
    By znum in forum C Programming
    Replies: 3
    Last Post: 05-12-2008, 04:14 PM
  3. Calculator using getchar, putchar
    By arlen20002000 in forum C Programming
    Replies: 5
    Last Post: 03-26-2008, 10:37 AM
  4. need help please! getchar, putchar, etc.
    By sue in forum C Programming
    Replies: 1
    Last Post: 03-21-2003, 08:40 PM