Hi all.
Before you all scream "search the forum", i already have, this and many others. cant seem to find the problem with my code.
Basically, i have a fairly large text file, each line consisting of 20 fields seperated by a `. i have got my program to split each line into an array (with a for loop), thats all fine.
Problemo starts when i want it to compare one of these fields (first one FYI) with a variable (char/std::string), and if it does not match, move to the next line of the file and so on.
more or less search the first field of the file for one particular string.
here is the code. (excuse us if i mess up the code /code thingy)
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdio.h>
using namespace std;
int main ()
{
char chrLine[1024];
char buffer[10000];
char *arrLine[20];
int iii = 2;
int bbb = 1;
fstream fsFile ("/home/kevin/PlantBatchRecord.txt");
while (fsFile.getline(chrLine,1024))
{
//fsFile.getline(chrLine,1024);
arrLine[1] = strtok(chrLine,"`");
cout << arrLine[1] << endl;
for(iii; iii<21;iii++)
{
arrLine[iii]= strtok(NULL,"`");
cout << arrLine[iii] << endl;
}
// cout << chrLine<< endl;
fsFile.getline(chrLine,1024);
}
fsFile.close();
return 0;
}
and heres a sample of the file its analysing:
-2136142810`DIGOD`1912181208`7/1/2009 0:00:00`14.00`34.00`476.00``6`30/12/1899 16:56:40`30/12/1899 15:26:58`2`0`0````0`{092DED01-4B2D-482F-953C-55AC25F5EEB2}`
-2135193690`LOAFFC`5453180308`20/3/2008 0:00:00`15.00`34.00`510.00``2`30/12/1899 16:40:15`30/12/1899 13:36:36`3`0`0````36`{9342CD21-0093-475F-8BA5-A6F96D69E55E}`
-2135193319`PHWINR`3522080708`15/7/2008 0:00:00`11.00`6.00`66.00``2`30/12/1899 16:04:34`30/12/1899 15:41:05`1`0`0````0`{20EE4310-5E16-4390-A32E-855CDDEF5B97}`
-2135134166`CTMAC`1502230408`2/5/2008 0:00:00`3.00`34.00`102.00`#7`0`30/12/1899 11:37:15`30/12/1899 8:57:21`2`0`0``0``0`{4CAA0FDB-D8A8-4875-93FF-31131FF40CA5}`
-2133567660`ECDICP`2262040408`7/4/2008 0:00:00`12.00`34.00`408.00``5`30/12/1899 16:24:40`30/12/1899 15:47:23`2`0`0````49`{174DFC95-202F-4060-9CC6-8ED7F87D8674}`
-2133511239`KABENFJ`4601060409`7/4/2009 0:00:00`22.00`34.00`748.00``6`30/12/1899 11:23:52`30/12/1899 9:29:22`2`0`0````0`{F7400055-E446-4A7F-946D-53F00041B633}`
-2133402358`GRCHER`3412131008`22/10/2008 0:00:00`32.00`34.00`1088.00``6`30/12/1899 13:01:12`30/12/1899 9:55:56`2`0`0````0`{017DA154-DCC4-4B17-9701-BA0CC14BBE66}`
ive tried many things, including puting a fsFile.get() at the end of the while loop, changing the while loop to a for or do while loop, getting rid of the cout statements within loop, everything i can think of, or thats been suggested in similar threads here and elsewhere.
Thanks all in advance for your help, or at least for reading my post =].