I have a file which contains these data:
- /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150616_072540.451_0_Front.Frontview.png, AspectRatio= 4.79245 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071755.852_0_Front.Frontview.png, AspectRatio= 4.24 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071800.060_0_Front.Frontview.png, AspectRatio= 4.3617 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071802.609_0_Front.Frontview.png, AspectRatio= 3.98214 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071805.559_0_Front.Frontview.png, AspectRatio= 4.31482 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071808.670_0_Front.Frontview.png, AspectRatio= 4.67925 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071818.289_0_Front.Frontview.png, AspectRatio= 4.45455 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071904.912_0_Front.Frontview.png, AspectRatio= 3.85455 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071906.760_0_Front.Frontview.png, AspectRatio= 4.87755 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071925.645_0_Front.Frontview.png, AspectRatio= 4.19298 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071928.516_0_Front.Frontview.png, AspectRatio= 4.30435 /opt/ADL_db/Users/mkhalil/PipeLineWork/ReferenceImageDB/20150612_071931.830_0_Front.Frontview.png, AspectRatio= 4.5
And i would like to find for example the line which has this sequence:
- 20150616_072540.451_0_Front.Frontview.png
I used string find , str compare after dividing the string into tokens and also strstr but it is not working
Code used
void ReadInvertedImageValue (string imagerequired)
{
char *FileName= "/opt/ADL_db/Users/mkhalil/PipeLineWork/aspectratiofilesInverted2.txt";
FILE * pFile;
char buffer [500];
pFile = fopen (FileName , "r");
if (pFile == NULL) perror ("Error opening file1");
else
{
while ( ! feof (pFile) )
{
if ( fgets (buffer , 400 , pFile) == NULL )
break;
char * pch;
pch = strtok (buffer,"/,");
pch = strtok (NULL, "/,");
pch = strtok (NULL, "/,");
pch = strtok (NULL, "/,");
pch = strtok (NULL, "/,");
pch = strtok (NULL, "/,");
pch = strtok (NULL, "/,");
string test=pch;
cout<<"Current line:"<<test<<endl;
if( test.compare(imagerequired) ==0 )
{
cout<<"Found: "<<buffer<<endl;
break;
}
/* string str=buffer;
std::size_t found = str.find(*imagerequired,55);
if (found!=std::string::npos)
{
cout<<"Found: "<<buffer<<endl;
break;
}*/
}
}
}
void ReadCommonfiles (const char* FileName)
{
FILE * pFile;
char buffer [400];
pFile = fopen (FileName , "r");
if (pFile == NULL) perror ("Error opening file1");
else
{
while ( ! feof (pFile) )
{
if ( fgets (buffer , 400 , pFile) == NULL )
input.push_back(buffer);
cout<<buffer<<endl;
ReadInvertedImageValue(buffer);
break;
}
}
}// End of the function
Aucun commentaire:
Enregistrer un commentaire