2. Standard Input and Output
 
int putchar(int)
– putchar(c) puts the character c on the standard output.
– it returns the character printed or EOF on error.
int getchar()
– returns the next character from standard input.
– it returns EOF on error.
To use a file instead of standard input or output, use ‘<‘ or ‘>’.
– input redirecton: prog < infile
– output redirecton: prog > outfile
 
Example
 
C:>a.exe < infile
#include <stdio.h>

int main ()
{
    char c;
    while ((c=getchar())!= EOF)
    {
        if ( c>=’A’ && c<=’Z’)
        c=c−’A’+’a’ ;
        putchar (c);
    }

    return 0;
}
 
 
 
 
이전페이지 / 3 / 다음페이지