1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
size_t found;
getline(rf,tempLine);
while (!rf.eof())
{
currentLineNumber++;
found= tempLine.find(requestedTarget);
while(found != string::npos)
{
totalTimesFoundInFile++;
totalTimesFoundOnLine++;
found=tempLine.find(requestedTarget, found+1);
}
if(totalTimesFoundOnLine != 0)
{
int n = sprintf(stringToSend, "Appeared on Line %d, %d times",currentLineNumber,
totalTimesFoundOnLine);
write(fd2, stringToSend, sizeof(stringToSend));
}
getline(rf,tempLine);
totalTimesFoundOnLine = 0;
}
int t = sprintf(stringToSend, "Appeared a Total of %d Times",totalTimesFoundInFile);
cout <<"Final string to send: " << stringToSend <<endl;
char finalLine[] = "final line";
write(fd2, finalLine, sizeof(finalLine));
cout <<"Just put 'finalLine' into pipe" <<endl;
write(fd2, stringToSend, sizeof(stringToSend));
cout <<"Just put final string into pipe" <<endl;
char endingMessage[]="Server-EOF";
write(fd2, endingMessage, sizeof(endingMessage));
|