Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. File Processing
  5. File Processing Operation...
  6. Write line to file

Write line to file

  • Write a line to a file
  •  It outputs string to a stream.

Syntax

fputs
int fputs(const char *s, FILE *stream)

s âˆ’ This is an array containing the null-terminated sequence of characters to be written.

stream − This is the pointer to a FILE object that identifies the stream where the string is to be written.

This function returns a non-negative value, or else on error it returns EOF.

Program

#include<stdio.h>  
int main()
{  
	FILE *fp;  
	fp=fopen("myfile2.txt","w");  
	fputs("hello c programming",fp);  
	fclose(fp);  
	return 0;
}

Output

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments