C Programming Language

fputc()

Declaration: int fputc(int ch,FILE *stream);

                   The fputc() function writes the character ch to the specified stream at the current file position and then advance the file position indicator. Even though the ch is declared to be an int , it is converted by fputc() into an unsigned char.

                      The value returned by the fputc() is the value of the character written . if an error occurs, EOF is returned.

For example, the following program writes to the specified stream.

#include <stdio.h>
#include<stdlib.h>
int main()
       {
       FILE *fptr;
       char text[100];
       int i=0;
       clrscr();
       printf(“Enter a text:\n”);
       gets(text);
       if((fptr = fopen(“TEST”,”w”))==NULL)
                  {
                   printf(“Cannot open file\n”);
                   exit(1);
                   }
        while(text[i]!=’\0’)
                     fputc(text[i++],fptr);
        if(fclose(fptr))
                     pritf(“File close error\n”);
        getch();
        return 0;
        }

fclose() Home fgetc()

Melbourne Nursing Agency jobs in Australia : Melbourne Nursing Agency jobs Palliative care nurse melbourne Home nursing care Melbourne in Australia
Custom ERP Developers Melbourne Custom ERP Developers in Melbourne in Australia

c program stats