Thread: splitting up files

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    99

    splitting up files

    hi, i have a input file for my program and its full of the same typ of structure, ive put an example below. I would idealy like to carve out the data inbetween <gg> and </gg> but so far im having trouble as the data can be varying length. So far I can find the occurance of the begining of the string but i dont know how to read the data until it reaches the ending criteria. I hope that made sense

    <gg>ADADDADADADADA </gg><gg>ADADDADADADffffADA </gg><gg>ADADDDA </gg>

    Code:
    string line;
    string str = "<gg>"
    
                   getline (infile,line);      	      
    	        size_t found;
    
    		if (  found = line.find(str));
                     {
    
                     }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So just find the next string, then use substr() to grab the portion between (you'll have to do some math to adjust for the length of the respective search items).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  5. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM