Загрузка...

Counting the number of lines in a file

Thread in C/C++ created by tyske Jan 13, 2017. 221 view

  1. tyske
    tyske Topic starter Jan 13, 2017 66 Oct 15, 2016
    Приложение, которое подсчитывает количество строк в файле.
    Разработку вести в среде CLR Console Application
    Code

    #include "stdafx.h"
    #include <stdio.h> //Для printf(), putchar(), getchar()
    #include <conio.h> //Для _getch()

    using namespace System;

    #define eof -1 //Признак конца файла

    int main()
    {
    int c,nl;
    nl=0;
    printf("Enter your string and press <Enter> and <Cntl + Z> >\n");
    while((c=getchar()) != eof)

    if (c == '\n')
    {
    nl++;

    }
    printf("String's number is: %d\n",nl);
    _getch();
    }
     
Loading...
Top