單一字元

  1. 範例:輸入一個字元。
    [dywang@deyu zzz]$ vim stdio1.c
    [dywang@deyu zzz]$ cat stdio1.c
    #include <stdio.h>
    
    int main() {
    	char c;
    
    	printf("Enter a character: ");
    	c = getchar( );
    	printf("You entered: ");
    	putchar(c);
    	printf("\n");
    }
    
  2. 編譯
    [dywang@deyu zzz]$ gcc -o stdio1 stdio1.c
    
  3. 執行結果
    [dywang@deyu zzz]$ ./stdio1
    Enter a character: A
    You entered: A