#include "stdafx.h"
#include "string.h"
#include <stdlib.h>
int _tmain(int argc, _TCHAR* argv[])
{
FILE *fp1, *fp2;
char ime[32], prezime[32]; char brojbodova[5];
fp1 = fopen("ulaz.txt", "r");
char linija[100];
char linijacopy[100];
while(fgets(linija, sizeof(linija), fp1) != NULL)
{
/* or this: while (!feof(fp1))
{
fgets(linija, sizeof(linija), (FILE*)fp1);
rest of code*/
strcpy(linijacopy, linija);
strcpy(ime, strtok(linija , " "));
strcpy(prezime, strtok(NULL, " "));
strcpy(brojbodova, strtok(NULL, " "));
int bbodova = atoi(brojbodova);
if(bbodova <= 50)
{
printf("%s\n", linijacopy);
}
}
fclose(fp1);
return 0;
}
When I build this solution I doesn't have any error, but when I run this program, after printing results I got following windows error:
Console application has stopped working.
Windows can check online for a solution to the problem. And there are three options: -Check online... -Close the program -Debug the program Problem details: Problem signature: Problem Event Name: APPCRASH Application Name: ConsoleApplication8.exe Application Version: 0.0.0.0 Application Timestamp: 5834b1c7 Fault Module Name: MSVCR110D.dll Fault Module Version: 11.0.50727.1 Fault Module Timestamp: 5011aa23 Exception Code: c0000005 Exception Offset: 0008f7b3 OS Version: 6.1.7601.2.1.0.256.1 Locale ID: 9242 Additional Information 1: 0a9e Additional Information 2: 0a9e372d3b4ad19135b953a78882e789 Additional Information 3: 0a9e Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
This program was typed in VS 2012 and OS is Windows 7 32 Enterprise.