Counts ascending FOR loops

According to the following rule (AVR035: Efficient C Coding for AVR, Rev. 1497D–AVR–01/04) : "9. Use descending loop counters and pre-decrement if applicable." , reducing code of the Atmel (NXP) company on AVR series microcontrollers, using the appropriate for loops, helps optimize the code at the file size level. 


// THIS PROGRAM COUNTS THE NUMBER OF ASCENDING FORS AND OUTPUTS THE LINE WHERE THEY BELONG


#include <iostream>

#include <fstream>

#include <string.h>

using namespace std;

ifstream fin ("file_in.ppc");



int main()

{

    int ct=0,lin=0;

    char linie[101];

    while(!fin.eof())

    {

        fin.getline(linie,100);

        lin++;

        if((strstr(linie,"for")>0) and (strstr(linie,"++")>0))

        {

            ct++;

            cout<<lin<<endl;

        }

    }


    fin.close();


    cout<<"Number of ASCENDING FOR: "<<ct<<endl;


    return 0;

}



Comentarii

Postări populare de pe acest blog

Optimized SWAP gate-circuit

STATEMENT COVERAGE