| | |
Searching a file for a string
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
•
•
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
(Your not using unix, when do one ever use console apps in windows ? go fetch mingw and tools )C++ Syntax (Toggle Plain Text)
char *arg[5] ; arg[0] = "grep" ; arg[1] = "-n" ; arg[2] = string.c_str() ; arg[3] = fileName.c_str() ; arg[4] = NULL ; execvp(arg[0], arg) ;
pokerponcho
•
•
•
•
Originally Posted by pokerponcho
If you think about 5 minutes before you knew this trick this post wouldn't be very helpful.
pokerponcho
•
•
•
•
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...
•
•
•
•
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...
•
•
•
•
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)..
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <string> int main( int argc, char **argv ) { std::string number ; std::cout << "What number do you want to factorize: " ; std::getline( std::cin, number ) ; std::string factors ; // so I'm stuck here, I could use some help implementing the general number field // sieve, perferable in a easily paralizable manner so that I can use all my // availible computers to solve the problem... // ofcourse if you have a faster algorithm for 100+ digits numbers I would appreciate // an implementation of that as well.... std::cout << number << " factors into " << factors << std::endl ; return 0 ; }
/end retort
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...
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
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: Please make my frist socket app work...
- Next Thread: Linked List & Objects
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






