fputs()函数fputs
语法:
1 2 |
?? #include <stdio.h> ?? int fputs( const char *str, FILE *stream ); |
fputs()函数把str(字符串)指向的字符写到给出的输出流. 成功时返回非负值, 失败时返回EOF.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include<stdio.h> #include<stdlib.h> int main() { char str[80]="asdhfdf\n"; FILE *fp = NULL; if((fp=fopen("strfile.txt","w"))==NULL) { printf("cannot open file\n"); exit(0); } fputs(str,fp); //putchar(str); fclose(fp); fp = NULL; return 0; } |