Hi all,
I have written some code to open a file and check for a tag (string) within that file.
No matter how it is coded, the result does not appear to be correct. The code should return 'found' if the string was in the file, and 'not found' otherwise, but it does not appear to work correctly. Here is a pesudo snippit...
pos = 0;
tag = argv[2];
infile.open(file);
while(infile.get(Ch))
{ // read and store the data in array 'data'
data[pos] = Ch;
outfile << Ch;
pos++;
}
infile.close();
if(strcmp(data,tag) == 0)
{ // check if 'tag' is in the array
printf("found\n"
}
else
{
printf("not found\n"
}
Essentially, i need to find a small string within a much larger one (that is the file).
Im sure im looking at this too simply, so if anyone can point me in the right direction it would be much appriciated. Thanks in advance.
Regards,
J@yb0t
"Always know what you say, but don't always say what you know!"
I have written some code to open a file and check for a tag (string) within that file.
No matter how it is coded, the result does not appear to be correct. The code should return 'found' if the string was in the file, and 'not found' otherwise, but it does not appear to work correctly. Here is a pesudo snippit...
pos = 0;
tag = argv[2];
infile.open(file);
while(infile.get(Ch))
{ // read and store the data in array 'data'
data[pos] = Ch;
outfile << Ch;
pos++;
}
infile.close();
if(strcmp(data,tag) == 0)
{ // check if 'tag' is in the array
printf("found\n"
}
else
{
printf("not found\n"
}
Essentially, i need to find a small string within a much larger one (that is the file).
Im sure im looking at this too simply, so if anyone can point me in the right direction it would be much appriciated. Thanks in advance.
Regards,
J@yb0t
"Always know what you say, but don't always say what you know!"