比較scanf的返回值與printf的返回值

scanf 函數 :


1 .scanf()函數有返回值且爲int型。
2.scanf()函數返回的值爲:正確按指定格式輸入變量的個數;也即能正確接收到值的變量個數。
例如 : #include<stdio.h>
       int main()
       {
        int a;
        int b;
        printf("%d\n", scanf("%d%d",&a,&c));
        }

在scanf中輸入了兩個整型的常量,則打印 「 2 」。

printf函數:


1. 返回 一個int值,表示被打印的字符數

例如 #include<stdio.h>
       int main()
       {
        printf("%d\n", printf("%d\n", printf("12\n")));
        printf("%d\n", printf("%d\n", printf("-12\n")));
      }
在第一行的第三個printf中是 「1」「 2」  「\n」 有這三個字符,則在第二個printf接收第三個的返回值 則打印   「2」  第一個                printf接收第二個的返回值 「2」 「\n"  打印」2「   
在第二行中 同上  注意「-」也是一個字符。。。