fputs in c

Solutions on MaxInterview for fputs in c by the best coders in the world

showing results for - "fputs in c"
Jessica
14 Jul 2016
1#include <stdio.h>
2
3int main () {
4   FILE *fp;
5
6   fp = fopen("file.txt", "w+");
7
8   fputs("This is c programming.", fp);
9   fputs("This is a system programming language.", fp);
10
11   fclose(fp);
12   
13   return(0);
14}
Nicole
29 Apr 2018
1#include <stdio.h>
2
3int main () {
4   FILE *fp;
5   int c;
6
7   fp = fopen("file.txt","r");
8   while(1) {
9      c = fgetc(fp);
10      if( feof(fp) ) {
11         break ;
12      }
13      printf("%c", c);
14   }
15   fclose(fp);
16   return(0);
17}
Alex
17 May 2020
1#include<stdio.h>
2#include<stdlib.h>
3int main()
4{ 
5  FILE *p;
6  int ch;
7  p=fopen("yourfile","w"))==NULL)
8  { 
9  printf("Errror");
10  exit(1);
11  }
12  printf("Enter the text:\n");
13  while(ch=getchar())!=EOF)
14  fputc(ch,p);
15  fclose(p);
16  return 0;
17}
similar questions
queries leading to this page
fputs in c