Program that counts "while" loops (excluding do-while loops)

 

#include <iostream>

#include <fstream>

#include <string.h>


using namespace std;

ifstream fin ("whilecount.txt");


int main()

{

    char linie[100];

    int nrtot_while=0, nr_linie=0;

    while(!fin.eof())

    {

        fin.getline(linie,100);

        nr_linie++;

        if (strstr(linie,"while")>0 && !( strstr(linie,";")>0))

        {

            nrtot_while++;

            cout << nr_linie << endl;

        }

    }

        cout << "Number of 'while' instructions in the file: " << nrtot_while;

    return 0;

}

//This program was designed in CodeBlocks - version 20.03 in the C /C++ language.

Comentarii

Postări populare de pe acest blog

Optimized SWAP gate-circuit

Counts ascending FOR loops

STATEMENT COVERAGE