Dear friends:
I have a txt file to read. I only need the number of ELEMENTS and the ENTITIY NAME. which function should i use to read in these two values.
Regards

GROUP:        2 ELEMENTS:         4 NODES:            2 GEOMETRY:    0 TYPE:   0
ENTITY NAME:   WALL_LEFT           
      33      16      10
      34      20      16
      35      23      20
      36      25      23

Recommended Answers

All 2 Replies

Your program will have to read them all into memory then keep only the ones you want.

>>which function should i use

Its not a function at all. Its called an algorithm. Use ifstream to open the file as a normal text file then in a loop use >> operator to read each of the columns in each row.

something like this will do:

ifstream infile;
     
    infile.open("datafile.txt");
      
    do
    { 
  
    infile>>elements>>entity;   
       
    }while(!infile.eof());

but you have to make it array

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.