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("kod.c", "rb");
if (p_File==0)
{
printf("Nie udalo się otworzyc pliku, byc moze plik nie istnieje?\n");
system("PAUSE");
return 1;
}
p_OutFile = fopen("raport.txt", "wb");
if(p_OutFile == 0)
{
printf("Nie udalo sie utworzyc pliku do zapisu.\n");
system("PAUSE");
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