answersLogoWhite

0

What is Fgetc and fputc in c?

Updated: 8/16/2019
User Avatar

Wiki User

15y ago

Best Answer

fgetc gets a character from a file using a file pointer.the syntax is fget(fp) where fp is a pointer to the file

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is Fgetc and fputc in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write c program to identify keywords using transition table?

#include#include#includevoid keyw(char str[10]){if(strcmp("for",str)==0)printf("%s is a keyword",str);else if(strcmp("while",str)==0)printf("%s is a keyword",str);else if(strcmp("char",str)==0)printf("%s is a keyword",str);else if(strcmp("int",str)==0)printf("%s is a keyword",str);else if(strcmp("if",str)==0)printf("%s is a keyword",str);else if(strcmp("else",str)==0)printf("%s is a keyword",str);elseprintf("%s is an identifier",str);printf("\n");}main(){FILE *f1,*f2,*f3;char c,str[10];int num[100],ln=0,tvalue=0,i=0,j=0,k=0;printf("Enter a C program expression");f1=fopen("input.c","w");while((c=getchar())!=EOF)fputc(c,f1);f1=fopen("input.c","r");f2=fopen("identifier.txt","w");f3=fopen("specialchars.txt","w");while((c=fgetc(f1))!=EOF){if(isdigit(c)){tvalue=c-'0';c=fgetc(f1);while(isdigit(c)){tvalue=tvalue*10+c-'0';c=fgetc(f1);}num[i++]=tvalue;ungetc(c,f1);}else if(isalpha(c)){fputc(c,f2);c=fgetc(f1);while((isdigit(c))isalpha(c)c==' 'c=='$'){fputc(c,f2);c=fgetc(f1);}fputc(' ',f2);ungetc(c,f1);}else if(c==' 'c=='\t');else if(c=='\n')ln++;elsefputc(c,f3);}fclose(f1);fclose(f2);fclose(f3);printf("Numbers in the program are \n");for(j=0;j


What are four file commands required to read and write a file?

these are not commands, but functions. Some of them are: open, close, read, write; fopen, fclose, fread, fwrite, fgets, fputs, fprintf, fscanf, fgetc, fputc.


How do you print on console without using printf or puts in c language?

write, putchar, putc, fputc etc


How do you write a C program which reads a C source file and creates a copy of that file with all comments removed?

#include<stdio.h> void strip_comments (FILE* input, FILE* output) { enum enum_mode {normal, slash, q1, q1b, q2, q2b, single, multi, star}; int ichar; enum_mode mode; mode = normal; while ((ichar=fgetc(input))!=EOF) { switch (mode) { case normal: switch (ichar) { case '/': mode=slash; break; case '\'': fputc (ichar, output); mode=q1; break; case '"': fputc (ichar, output); mode=q2; break; default: fputc (ichar, output); } break; case slash: switch (ichar) { case '/': mode=single; break; case '*': mode=multi; break; default: fputc ('/', output); fputc (ichar, output); mode=normal; } break; case q1: switch (ichar) { case '\\': fputc ('\\', output); mode=q1b; break; case '\'': fputc (ichar, output); mode=normal; break; default: fputc (ichar, output); } break; case q1b: fputc (ichar, output); mode=q1; break; case q2: switch (ichar) { case '\\': fputc (ichar, output); mode=q2b; break; case '"': fputc (ichar, output); mode=normal; break; default: fputc (ichar, output); } break; case q2b: fputc (ichar, output); mode=q2; break; case single: switch (ichar) { case '\r': case '\n': fputc (ichar, output); mode=normal; break; } break; case multi: switch (ichar) { case '*': mode=star; break; } break; case star: switch (ichar) { case '/': mode=normal; break; default: mode=multi; } break; } } } int main (int argc, char* argv[]) { if (argc!=3) { char* prog; prog=argv[0]; while (*prog!=0) ++prog; while (*prog!='.') { *prog=0; --prog; } *prog=0; while (*prog!='\\') --prog; ++prog; fprintf(stderr, "Comment stripper for C/C++ source files\n"); fprintf(stderr, "Copyright © 2016, PCForrest\n\n"); fprintf(stderr, "Usage:\n\n%s src dst\n\n", prog); fprintf(stderr, " src - source file\n"); fprintf(stderr, " dst - destination file\n\n"); return -1; } FILE* source; FILE* destination; source=fopen(argv[1], "r"); destination=fopen(argv[2], "w"); if (!source !destination) { if (source) fclose (source); if (destination) fclose (destination); return -1; } strip_comments (source, destination); fclose (source); fclose (destination); return 0; }


What is function get in C programming?

There is no 'get' in the standard libraries, but for 'getc', 'getch', 'getchar', 'fgetc' etc you can find useful information in the help/manual.


7 Write a program to append one file at the end of another?

#include#includevoid main(){FILE *fp1,*fp2;char ch,fname1[20],fname2[20];printf("\n enter sourse file name");gets(fname1);printf("\n enter sourse file name");gets(fname2);fp1=fopen(fname1,"r");fp2=fopen(fname2,"a");if(fp1==NULLfp2==NULL){printf("unable to open");exit(0);}do{ch=fgetc(fp1);fputc(ch,fp2);}while(ch!=EOF);fcloseall();}


Write a program that outputs the source code of a program?

#include <stdio.h> main() { FILE *fd; int c; fd= fopen("./file.c","r"); while ( (c=fgetc(fd)) != EOF) { printf("%c", c); } fclose(fd); }


How do you read line by line of a file in c program?

read, fread, fgetc, fgets, fscanf etc... use the help/manual


Is that any other way to input data in c language other than scanf function?

read, fread, gets, fgets, getc, fgetc, getchar, getch


Write a c program to display hello on the monitor without using printf?

You can choose from puts, fputs, fwrite, write (or even putchar, putc, fputc). I hope this will help you to start.


How do you read the number of capital letters in a input file using c language?

#include <stdio.h> #include <ctype.h> ... int caps = 0; int c; file = fopen ("InputFile", "r"); while ((c = fgetc (file)) != EOF) { if (isupper (c)) ++caps; } fclose(file); ...


Write a program to copy the contents of one file to another?

#include<stdio.h> #include<conio.h> int main(int x,char *a[]) { FILE *fp1,*fp2; fp1=fopen("input.txt","r"); fp2=fopen("output.txt","w"); while(!(feof(fp1))) { fputc(fgetc(fp1),fp2); } fclose(fp1); fclose(fp2); return 0; }