Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by Robert ( 14 years ago )
#include <stdio.h>
#include <stdlib.h>


typedef unsigned int ui;
int main()


{   ui OpenBracketCount;
    ui ClosedBracketCount;
    ui FileSize;
    ui LineOfCode;
    int c;
    
    OpenBracketCount=0;
    ClosedBracketCount=0;
    LineOfCode=1;
    
    FILE* p_File;
    FILE* p_OutFile;
    
    p_File = fopen&#40;"kod.c", "rb"&#41;;
    
    if (p_File==0)
    {
        printf("Nie udalo się otworzyc pliku, byc moze plik nie istnieje?\n");
        system&#40;"PAUSE"&#41;;
        return 1;
        
    }
    p_OutFile = fopen&#40;"raport.txt", "wb"&#41;;
    
    if(p_OutFile  == 0)
    {
        printf("Nie udalo sie utworzyc pliku do zapisu.\n");
        system&#40;"PAUSE"&#41;;
        fclose(p_File);
        return 2;
    }
    fseek(p_File, 0, SEEK_END);  
    FileSize = ftell(p_File);      
    fseek(p_File, 0, SEEK_SET);
    
    while(ftell(p_File) < FileSize)
    {
        c = fgetc (p_File);
        if (c=='{')
        {
            OpenBracketCount++;
            fprintf (p_OutFile, "Znaleziono lewą klamerke, linia kodu:%u\n", LineOfCode);
        }
        
        if (c=='}') 
        {
            ClosedBracketCount++;
            fprintf (p_OutFile, "Znaleziono prawą klamerke, linia kodu:%u\n", LineOfCode);
        }
        if (c=='\n') LineOfCode++;
        
    }
    fclose(p_File);
    fclose(p_OutFile);
    return 0;
}

 

Revise this Paste

Parent: 43348
Your Name: Code Language: