Hi guys, im experimenting with vector functions, but are unable to come up with anythin constructive.

basically i have this file that contains information. sorta like a friends list. I need to store in an array, and i decided to use vectors for this. Any help please?

data.txt

<div id="featured" class="component">
      <div class="header">
        <h2 class="header-title">List </h2>
      </div>
      <div class="content">

<div class="container">
      
        
	 <div class="dd">
     
	  
	  
	 </div>

        
        <div class="fr_num">1.</div>
        <div class="fr_name">Gary</div>
        
        
	 <div class="dd">
     
	  
	  
	 </div>
        
        <div class="fr_num">2.</div>
        <div class="fr_name">Alex</div>
        
        
	 <div class="dd">

     
	  
	  
	 </div>
        
        <div class="fr_num">3.</div>
        <div class="fr_name">Mollyr</div>
        
        
	 <div class="dd">
     
	  
	  
	 </div>
        
        <div class="fr_num">4.</div>
        <div class="fr_name">Spunk</div>

        
        
	 <div class="dd">
     
	  
	  
	 </div>
        
        <div class="fr_num">5.</div>
        <div class="fr_name">Dida</div>
        
        
	 <div class="dd">
     
	  
	  
	 </div>
        
        <div class="fr_num">6.</div>

        <div class="fr_name">Telex</div>
        
        
	 <div class="dd">
     
	  
	  
	 </div>
        
        <div class="fr_num">7.</div>
        <div class="fr_name">Sunny</div>
        
        
	 <div class="dd">
     
	  
	  
	 </div>

        
        <div class="fr_num">8.</div>
        <div class="fr_name">Tether</div>
        
        
	 <div class="dd">
     
	  
	  
	 </div>
        
        <div class="fr_num">9.</div>
        <div class="fr_name">DiscoDuck</div>
        
        
      
	</div>

    <div class="footer3"></div>
  </div>

Edited 6 Years Ago by watery87: error

When a line of text is read from the file check to see if it contains "fr_name". If it does, then extract the name and put it into the vector. std::vector<std::string> friends;

do u mean using line.find?

for example line.find("fr_name"); then proceeding to put into std::vector<std::string> friends; ?

This article has been dead for over six months. Start a new discussion instead.