Click here to Skip to main content
15,893,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: STL destructor Pin
mjackson1112-Mar-09 16:41
mjackson1112-Mar-09 16:41 
AnswerRe: STL destructor Pin
Rajasekharan Vengalil12-Mar-09 17:32
Rajasekharan Vengalil12-Mar-09 17:32 
AnswerRe: STL destructor Pin
Sarath C12-Mar-09 20:58
Sarath C12-Mar-09 20:58 
Questionquery Pin
anassamar12-Mar-09 11:38
anassamar12-Mar-09 11:38 
AnswerRe: query Pin
Stuart Dootson12-Mar-09 11:59
professionalStuart Dootson12-Mar-09 11:59 
AnswerRe: query Pin
David Crow12-Mar-09 16:37
David Crow12-Mar-09 16:37 
AnswerRe: query Pin
A_xin12-Mar-09 23:51
A_xin12-Mar-09 23:51 
QuestionContains [modified] Pin
su_penguin12-Mar-09 11:16
su_penguin12-Mar-09 11:16 
Hello all,

With C++ I/O functions, I'm trying to read in file contents but search for a particular point in the file. For example:

int main() {
	
    string line;
    
    ifstream inFile;
    
    inFile.open("C:\\LOCATIONOFFILE\\Desktop\\the.msg");
    if (!inFile) {
        cout << "Unable to open file";
        exit(1); // terminate with error
    }
    
    if (inFile.is_open())
  {
    while (! inFile.eof() )
    {
      getline (inFile,line);
      cout << line << endl;
	  
    }
    inFile.close();
  }
    return 0;


This reads in the first line of the file.
1. Is there a way to read in a specific line number? Something like getline (inFile,lineNumber100) ?
2. Can I point to a specific position in the line?
3. How can I apply regex to this in order to search entire files for particular strings in a file?

Sorry to be a pain but, if anyone can help...

Thanks

modified on Thursday, March 12, 2009 5:54 PM

AnswerRe: Contains Pin
Stuart Dootson12-Mar-09 11:56
professionalStuart Dootson12-Mar-09 11:56 
GeneralRe: Contains Pin
Rajasekharan Vengalil12-Mar-09 17:46
Rajasekharan Vengalil12-Mar-09 17:46 
QuestionA class within a class Pin
Chris Copeland12-Mar-09 10:42
mveChris Copeland12-Mar-09 10:42 
AnswerRe: A class within a class Pin
CPallini12-Mar-09 11:09
mveCPallini12-Mar-09 11:09 
AnswerRe: A class within a class Pin
Stuart Dootson12-Mar-09 11:10
professionalStuart Dootson12-Mar-09 11:10 
GeneralRe: A class within a class Pin
Chris Copeland12-Mar-09 11:19
mveChris Copeland12-Mar-09 11:19 
GeneralRe: A class within a class Pin
Stuart Dootson12-Mar-09 11:31
professionalStuart Dootson12-Mar-09 11:31 
GeneralRe: A class within a class Pin
Chris Copeland12-Mar-09 11:32
mveChris Copeland12-Mar-09 11:32 
GeneralRe: A class within a class Pin
Stuart Dootson12-Mar-09 11:58
professionalStuart Dootson12-Mar-09 11:58 
GeneralRe: A class within a class Pin
Chris Copeland12-Mar-09 12:01
mveChris Copeland12-Mar-09 12:01 
GeneralRe: A class within a class Pin
Stuart Dootson12-Mar-09 12:08
professionalStuart Dootson12-Mar-09 12:08 
GeneralRe: A class within a class Pin
Chris Copeland12-Mar-09 12:18
mveChris Copeland12-Mar-09 12:18 
QuestionMemory Checker Tools Pin
BobInNJ12-Mar-09 9:49
BobInNJ12-Mar-09 9:49 
QuestionRe: Memory Checker Tools Pin
David Crow12-Mar-09 10:06
David Crow12-Mar-09 10:06 
AnswerRe: Memory Checker Tools Pin
BobInNJ12-Mar-09 10:09
BobInNJ12-Mar-09 10:09 
GeneralRe: Memory Checker Tools Pin
David Crow12-Mar-09 10:12
David Crow12-Mar-09 10:12 
GeneralRe: Memory Checker Tools Pin
BobInNJ12-Mar-09 10:15
BobInNJ12-Mar-09 10:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.