C語言裏的puts()函數怎麼用

puts()函數是C語言中的輸出函數。
uts()函數用來向標準輸出設備(屏幕)寫字符串並換行,其調用方式爲,puts(s);其中s爲字符串字符(字符串數組名或字符串指針)。
函數原型:int puts(const char *string);
參數:string const的字符類型的指針
返回值: int類型,執行成功輸出的字節數,執行失敗返回EOF。
注意:puts輸出字符串時要遇到'\0’也就是字符結束符才中止,因此在字符串的最後一個要是 '\0'符。
實例:
#include <stdio.h>
#include <conio.h>
int main(void)
{
int i;
char string[20];
for(i=0;i<10;i++)
string[i]='a';
string[10]='\0';//注意
puts(string);
getch();
return 0;
}數組

相關文章
相關標籤/搜索