Write a C program to write a sentence into a file.

#include<stdio.h>
main()
{
    int i;
    char str[100];
    FILE *fp;
    fp=fopen("out.txt","w");
    printf("\nEnter a sentence=");
    gets(str);
    fprintf(fp,"%s",str);
    fclose(fp);
}

No comments:

Post a Comment