View Single Post
Join Date: Aug 2005
Posts: 15,171
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1439
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: find string in txt file

 
0
  #3
Dec 2nd, 2008
>>string ****Nipples;

OMG what in hell are you trying to do here??? If you are trying to code an array of string's then its string Nipples[4];
But the reading part should look like this: (I hope you change the variable names before turning in the assignment because your teacher may not be that humerious.)
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. ifstream RapidShit ("C:\\Rapid.txt");
  10. vector<string> Nipples; // an array of strings
  11. string line; // one line in the file
  12.  
  13. if(RapidShit.is_open())
  14. {
  15. while (getline(RapidShit, line) )
  16. {
  17. Nipples.push_back(line); // add to the array
  18. }
  19. // now you have the entire file in memory. Search each line
  20. // for the desired entry.
  21. }
  22. cin.get();
  23. return 0;
  24. }
Last edited by Ancient Dragon; Dec 2nd, 2008 at 8:37 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote