How to Read Files in C Language

How to Read Files in C Language
/*
Example:how to read from a file in C language
*/
#include <stdio.h>
#include <stdlib.h>

int main(){
	// Open file in read-only mode
    FILE *in=fopen("filename.txt","r");
    char c;
    while((c=fgetc(in))!=EOF)
        putchar(c);
    fclose(in); // close the file
    return 0;
}
Source:ww‮.w‬lautturi.com

Note that the parameters in fopen use double quotation marks. exceptions will occur if single quotation marks are used.

Created Time:2017-08-29 08:22:34  Author:lautturi