Searching a file for a string

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2005
Posts: 15,454
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: 1476
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Searching a file for a string

 
0
  #11
Nov 27th, 2005
Originally Posted by perniciosus
About color check, Ancient Dragons post, that was what I was talking about...
very similar to code tags but use color tags insted
[ color = <color here> ] and [ /color ]
(remove the spaces from the above)

Example in red
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 10
Reputation: pokerponcho is an unknown quantity at this point 
Solved Threads: 0
pokerponcho's Avatar
pokerponcho pokerponcho is offline Offline
Newbie Poster

Re: Searching a file for a string

 
0
  #12
Nov 27th, 2005
Originally Posted by perniciosus
no need to redo what has already been done
grep -n word file
or to use it in that context once you got the string do
  1. char *arg[5] ;
  2. arg[0] = "grep" ; arg[1] = "-n" ; arg[2] = string.c_str() ; arg[3] = fileName.c_str() ;
  3. arg[4] = NULL ;
  4. execvp(arg[0], arg) ;
(Your not using unix, when do one ever use console apps in windows ? go fetch mingw and tools )
If you think about 5 minutes before you knew this trick this post wouldn't be very helpful.
pokerponcho
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 10
Reputation: pokerponcho is an unknown quantity at this point 
Solved Threads: 0
pokerponcho's Avatar
pokerponcho pokerponcho is offline Offline
Newbie Poster

Re: Searching a file for a string

 
0
  #13
Nov 27th, 2005
Originally Posted by pokerponcho
If you think about 5 minutes before you knew this trick this post wouldn't be very helpful.
What I'm saying is that you shouldn't try to make someone feel bad for not knowing what you already learned. There once was a time where you were the same way.
pokerponcho
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 78
Reputation: perniciosus is an unknown quantity at this point 
Solved Threads: 4
perniciosus's Avatar
perniciosus perniciosus is offline Offline
Junior Poster in Training

Re: Searching a file for a string

 
0
  #14
Nov 27th, 2005
Hey, I was very thankful when I got to know about exec, now that is a convenient system call...
/pern.*/i

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Searching a file for a string

 
0
  #15
Nov 27th, 2005
Originally Posted by perniciosus
And I dont consider producing code that could just as well be copy pasted from just about any project showing that he has tried to understand or solve the problem...
Well...determining this, is subject to the individual's intelligence so I need not comment.
Originally Posted by perniciosus
and if you read his post you se that he says nothing about what operating system he is using, so I could just as well assume he was using linux and was nice enough to point out what to do if he was not...
What a valid assumption. Now it is all beginning to make sense. :rolleyes:


Originally Posted by perniciosus
]Mind solving this one:
You guys I was given a task to solve the integer factorization problem efficiently, preferable using the general number field sieve, mind helping me out (look code, I have made an effort)..
  1. #include <iostream>
  2. #include <string>
  3. int main( int argc, char **argv )
  4. {
  5. std::string number ;
  6. std::cout << "What number do you want to factorize: " ;
  7. std::getline( std::cin, number ) ;
  8. std::string factors ;
  9. // so I'm stuck here, I could use some help implementing the general number field
  10. // sieve, perferable in a easily paralizable manner so that I can use all my
  11. // availible computers to solve the problem...
  12. // ofcourse if you have a faster algorithm for 100+ digits numbers I would appreciate
  13. // an implementation of that as well....
  14. std::cout << number << " factors into " << factors << std::endl ;
  15. return 0 ;
  16. }
Saw that the question does not show genuine effort :cheesy: . Also I dont know the Alogorithm too. Better to say you dont know rather than make whatever reply you can think of.
/end retort
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 78
Reputation: perniciosus is an unknown quantity at this point 
Solved Threads: 4
perniciosus's Avatar
perniciosus perniciosus is offline Offline
Junior Poster in Training

Re: Searching a file for a string

 
0
  #16
Nov 28th, 2005
Well the point was that neither do I, and I am not likely to understand a solution you provide me with even if it was richly documented... From the code given it looked like he had gotten so far as to get a file name and a string to search for, and this would be a solution to the problem stated... He probably learned as much from my answer as from copy pasting what ever someone else neatly wrote down and perhaps error checked that fit directly into his code...

And of course lastly, all hail the BOFH...
/pern.*/i

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC