新聞中心
在C語言中,換行可以通過以下幾種方式實現(xiàn):

成都創(chuàng)新互聯(lián)公司專注于企業(yè)成都全網(wǎng)營銷、網(wǎng)站重做改版、郯城網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5頁面制作、成都做商城網(wǎng)站、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為郯城等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
1、使用轉(zhuǎn)義字符`
:在字符串中插入
`可以實現(xiàn)換行。
#includeint main() { printf("Hello, World! "); printf("This is a new line. "); return 0; }
2、使用r和`
組合:r表示回車,
表示換行,在Windows系統(tǒng)中,可以使用r
`組合實現(xiàn)換行。
#includeint main() { printf("Hello, World!r "); printf("This is a new line.r "); return 0; }
3、使用puts()函數(shù):puts()函數(shù)會自動在字符串末尾添加換行符。
#includeint main() { puts("Hello, World!"); puts("This is a new line."); return 0; }
4、使用fputs()函數(shù):fputs()函數(shù)可以將字符串寫入指定的文件,并在字符串末尾自動添加換行符。
#includeint main() { fputs("Hello, World! ", stdout); fputs("This is a new line. ", stdout); return 0; }
5、使用printf()函數(shù)的格式化輸出:通過printf()函數(shù)的格式化輸出,可以在指定位置插入換行符。
#includeint main() { printf("Hello, World! "); printf("%s", "This is a new line. "); return 0; }
| 方法 | 示例代碼 | 說明 |
| 轉(zhuǎn)義字符`
| printf("Hello, World!
") | 在字符串中插入
`實現(xiàn)換行 |
| `r
組合 | printf("Hello, World!r
") | 在Windows系統(tǒng)中使用r
`組合實現(xiàn)換行 |
puts()函數(shù) | puts("Hello, World!") | puts()函數(shù)會自動在字符串末尾添加換行符 |
| fputs()函數(shù) | `fputs("Hello, World!
", stdout)` | 將字符串寫入指定的文件,并在字符串末尾自動添加換行符 |
| 格式化輸出 | `printf("Hello, World!
") | 通過printf()`函數(shù)的格式化輸出,在指定位置插入換行符 |
網(wǎng)站題目:c語言怎么換行
轉(zhuǎn)載源于:http://fisionsoft.com.cn/article/coddced.html


咨詢
建站咨詢
