User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 426,563 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,726 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums

Searching a file for a string

Join Date: Nov 2005
Posts: 78
Reputation: perniciosus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 3
perniciosus's Avatar
perniciosus perniciosus is offline Offline
Junior Poster in Training

Re: Searching a file for a string

  #2  
Nov 26th, 2005
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
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) ;
(Your not using unix, when do one ever use console apps in windows ? go fetch mingw and tools )
Reply With Quote  
All times are GMT -4. The time now is 9:03 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC