English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C language reference manual
La función fputs() escribe una línea de caracteres en un archivo. Escribe una cadena al flujo.
Sintaxis:
int fputs(const char *s, FILE *stream)
#include<stdio.h> #include<conio.h> void main(){ FILE *fp; clrscr(); fp=fopen("myfile2.txt","w"); fputs("hello c programming",fp); fclose(fp); getch(); }
myfile2.txt
hello c programming
La función fgets() lee una línea de caracteres de un archivo. Obtiene una cadena desde el flujo.
Sintaxis:
char* fgets(char *s, int n, FILE *stream)
#include<stdio.h> #include<conio.h> void main(){ FILE *fp; char text[300]; clrscr(); fp=fopen("myfile2.txt","r"); printf("%s",fgets(text,200,fp)); fclose(fp); getch(); }
Salida:
hello c programming