Hi friends ,
:(
I've made a programme that can read a file and if it finds a peticular string in the file it shows the whole
line. I've used "stringstream" to extractone by one and I checked that by the If loop on true condition it prints
the whole line............
:icon_question:
Now the problem is that It works well with a small file but if the file is very large say 4MB it skips some of
the initial line that contains the string by which I'm searching in file.....................:-O
Mainfact:
What is the problem I could not understand Am I mistaking somewhere in using stringstream to read a large file
Or there is other way of doing this...................
my programme is as below.....
:idea:
1. #include<iostream>
2. #include<fstream>
3. #include<sstream>
4.
5. using namespace std;
6.
7.int main()
8.{
9. string s,z,x;
10. stringstream sstr;
11. ifstream ifle("aspect.txt");
12.
13. cin>>s;
14.
15. while(!getline(ifle,x).eof()) {
16 sstr<<x;
17. while(sstr>>z) {
18. if(z==s) {
19. cout<<x<<endl;
20. }
21. }
22. }
23.
24. ifle.close();
25.
26. return 0;
27.}
Pls help me to get out of this problem......................