C語言基礎 輸入輸出函數

來源:互聯網
上載者:User

標籤:

1.最常用scanf和printf,要包含標頭檔stdio.h
    
        1.1輸出printf
    
            格式:    printf("<格式化字串>", <參量表>)
                
            1.1.1 ""內包含3種物件類型的一個字串
                *無格式字元直接複製到輸出資料流    即一般字元直接輸出
                *帶格式符的按對應資料類型輸出    如:%d-整數 %s-字串
                *逸出字元   按轉義進行輸出,例如\n輸出斷行符號,\t輸出製表
            1.1.2 控制顯示值寬度

 1 int x = 18; 2 printf("x=%1d", x); // 輸出x=18  3 printf("x=%3d", x); // 輸出x= 18 4 printf("x=%5d", x); // 輸出x=   18 5  6 printf("x=%-1dT", x); // 輸出x=18T 7 printf("x=%-3dT", x); // 輸出x=18 T 8 printf("x=%-5dT", x); // 輸出x=18   T 9                     10 double x = 1.5;11 printf("x=%fT", x); // 輸出x=1.500000T12 printf("x=%10fT", x); // 輸出x=  1.500000T13 printf("x=%10.3fT", x); // 輸出x=     1.500T14 15 printf("x=%-8.3fT", x); // 輸出x=1.500   T16 printf("x=%-fT", x); // 輸出x=1.500000T17 printf("x=%-2.2fT", x); // 輸出x=1.50T

1.2輸入scanf
            格式:    scanf("<格式說明字串>",<變數地址>);

            1.2.1

C語言基礎 輸入輸出函數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.