Search
 
SCRIPT & CODE EXAMPLE
 

C

get file ligne count c


#include <stdio.h>

int main()
{

    FILE *fileptr;
    int count_lines = 0;
    char filechar[40], chr;


    printf("Enter file name: ");
    scanf("%s", filechar);
    fileptr = fopen(filechar, "r");
   //extract character from file and store in chr
    chr = getc(fileptr);
    while (chr != EOF)
    {
        //Count whenever new line is encountered
        if (chr == 'n')
        {
            count_lines = count_lines + 1;
        }
        //take next character from file.
        chr = getc(fileptr);

    }
    fclose(fileptr); //close file.
    printf("There are %d lines in %s  in a file
", count_lines, filechar);
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: C Nested if...else 
C :: C program determines the height status for heights in cm 
C :: allocate a array on strings in c 
C :: copy a number of characters to another string in c without standard library 
C :: taking input and converting it to a string in c 
C :: panagram in c 
C :: convert curl to http request with authorization header 
C :: captive portal esp8266 
C :: largest value in u32 
C :: how to turn off bash 
C :: payement des véhicules a la sortie de station de langue c 
C :: print binary in c 
C :: sdl_rect 
C :: float 
C :: calculate max of three numbers using ternary operator in c 
C :: compile opencv program 
C :: c check if is a right triangle 
Dart :: dart remove last character from string 
Dart :: flutter disbal PageView swipe 
Dart :: how to give shape to card in flutter 
Dart :: flutter replace character in string 
Dart :: flutter return empty widget 
Dart :: How can I add shadow to the widget in flutter? 
Dart :: remove menu icon from appbar flutter 
Dart :: alertdialog flutter outside click disble 
Dart :: dart map foreach 
Dart :: flutter firestore update 
Dart :: convert long to date android 
Dart :: dart typeof 
Dart :: elevatebutton in flutter 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =