Hello!
Can anyone help me... I have *.txt file containing lines like...
100 0 0 7 high UNLOCKED CRITICAL Door open in site CLEARED
100 11 0 7 low UNLOCKED CRITICAL Door Open CLEARED
100 12 0 0 high UNLOCKED CRITICAL Power suppy CLEARED
100 12 0 1 high UNLOCKED CRITICAL Fire CLEARED
100 12 0 2 low UNLOCKED CRITICAL Temperature CLEARED
Code is...
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
//norādam failu, kuru nolasam
FILE *statistic = fopen ("C:\\Tele2\\ENVAS\\Confenvarc1-0512.txt", "r");
//izveidojam output failu, kas tiek papildināts
FILE *envas = fopen ("C:\\Tele2\\ENVAS\\RC1.txt", "a");
//lasam failu
while (!feof(statistic))
{
char key[4];
int trash[3];
char string[10];
char line[200];
fgets (line,200,statistic);
sscanf (line,"%d %d %d %d %s", &trash[0], &trash[1], &trash[2], &trash[3], &key[0]);
if( key=="high" )
{
printf("%s",line);
// fprintf(envas,"%s",line);
}
}
fclose (statistic);
fclose (envas);
system("PAUSE");
return EXIT_SUCCESS;
}
As you see I'm trying to find lines containing word "high", but it returns empty screen... If there is some error in script...???