C Program to read text File on Disk using FREAD function

C Program to read text File on Disk using FREAD function 


Its Basic C Program to read any text from disk using FRead Function which belongs to stdio.h, using this function with file pointers you can read the TEXT contents of any file. 

#include 
#include 

int main()
{
    int cur_char;
    FILE *out_file;

    out_file = fopen("test.txt", "w");
    if (out_file == NULL) {
        fprintf(stderr,"Can not open output file\n");
        exit (8);
    }

    for (cur_char = 0; cur_char < 128; ++cur_char) {
        fputc(cur_char, out_file);
    }
    fclose(out_file);
    return (0);
}




No comments:

Post a Comment