Thread: parsing

  1. #1
    natasha
    Guest

    parsing

    a line from a text file is

    "mere thinking is nothing" 50

    now is there any function by which i can save the contents from the line between the two quotes only into a character array variable

  2. #2
    Registered User Strider's Avatar
    Join Date
    Aug 2001
    Posts
    149
    Use the ignore functonality to skip the first quotation mark, then read in the string using the getline function while specifying the quotation mark as the delimiter.
    Code:
    #include <iostream> 
    #include <fstream>
    
    using namespace std;
    
    int main() 
    { 
    	ifstream inText("message.txt", ios::in);
    	char message[50] = {'\0'};
    
    	inText.ignore(1);
    	inText.getline(message,50,'"');
    	inText.close();
    
    	cout << message << endl;
    
    	return 0; 
    }
    David
    One Ring to rule them all, One Ring to find them,
    One Ring to bring them all and in the darkness bind them
    In the Land of Mordor where the Shadows lie.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need sth about parsing
    By Masterx in forum C++ Programming
    Replies: 6
    Last Post: 11-07-2008, 12:55 AM
  2. draw tree graph of yacc parsing
    By talz13 in forum C Programming
    Replies: 2
    Last Post: 07-23-2006, 01:33 AM
  3. Parsing for Dummies
    By MisterWonderful in forum C++ Programming
    Replies: 4
    Last Post: 03-08-2004, 05:31 PM
  4. Need help fixing bugs in data parsing program
    By daluu in forum C Programming
    Replies: 8
    Last Post: 03-27-2003, 06:02 PM
  5. I hate string parsing with a passion
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-19-2002, 07:30 PM