Chapter:

Data-Files

Write a C Program to count Number of Characters in a File

#include <stdio.h> 

#include <stdlib.h> // For exit() 

#define MAX_FILE_NAME 100 

void  main() 

    FILE* fp; 

    int count = 0; 

    char filename[MAX_FILE_NAME]; 

    printf("Enter file name: "); 

    scanf("%s", filename); 

    // Open the file 

    fp = fopen(filename, "r"); 

    // Check if file exists 

    if (fp == NULL) { 

        printf("Could not open file %s", 

               filename); 

&nb....

Show More

All Chapters

View all Chapter and number of question available From each chapter from C-programming-