Getchar
eharetea

Two methods of using getchar() function in C to input characters and echo them to the textport.

Getchar function in C.

Date Created:Saturday March 24th, 2007 12:11 PM
Date Modified:Sunday August 03rd, 2008 11:41 AM


/*
* Author: Dan Lynch
*/

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;
    printf("Enter in some characters\n");    
    ch getchar();
    while (ch!='\n')
    {
        putchar(ch);
        ch=getchar();
    }

    return 0;
}




#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;
    printf("Enter some characterss\n");
    while( ( ch=getchar() ) != '\n' )
        putchar(ch);

    return 0;
}




Downloads:
Download: getchar.c 236 B
Download: getchar2.c 176 B

Please login or Click Here to register for downloads
Creative Commons License
Getchar by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com