C program to write a string in the file

Program:

#include<stdio.h>


void main()

{

    char str[20];

FILE *out;

out=fopen("file1.txt","w");

printf("Enter string: ");

gets(str);

fputs(str,out);

fclose(out);

}


Output:

Enter string: Hello World!


Drafted on 🌏 by,

Jal


peace

Comments

Popular posts from this blog

C program to read and display book information using structure

Count positive, negative and zero values in an array

Maximum value from array