How to use fputs() function to write a string to a file in C

1 Answer

0 votes
#include <stdio.h>
   
int main(void)
{
	FILE *fp = fopen("d:\\data.txt", "w");

    if (fp == NULL) 
		perror ("Error open file");
    else
    {
		 fputs("c programming is fun", fp);
		
        fclose(fp);
    }
	
    return 0;
}
  
// file content: c programming is fun
 
 
/*
run:
  


*/

 



answered May 4, 2016 by avibootz

Related questions

...