Searching text in a file

U

utab

Hi,

assume that I am working with a data file like this
====================================Patran .bdf file for CAE
$ file management section
$ -----------------------
$ -------------------------
$ executive control section
$ -------------------------
SOL 103
TIME 100000
CEND
$ --------------------
$ case control section
$ --------------------
ECHO = NONE
METHOD = 1
DISP = ALL
PARAM,COUPMASS,1
PARAM,OLDSEQ,-1
$ -----------------
$ bulk data section
$ -----------------
BEGIN BULK
$
PARAM AUTOSPC YES
PARAM GRDPNT 0
$
EIGRL 1 1. 10000. 20 0
MASS
$ property definitions
PBARL 1 1 BAR
0.4 0.4
$ material definitions
MAT1 1 21.E+10 0.3 7800.
$ grid point definitions (HERE STARTS Note parantheses and contents are
not a part of the file!)
GRID 1 0 0.0 0. 0. 0 123456
GRID 2 0 0.1 0. 0. 0 345
GRID 3 0 0.2 0. 0. 0 345
GRID 4 0 0.3 0. 0. 0 345
GRID 5 0 0.4 0. 0. 0 345
GRID 6 0 0.5 0. 0. 0 345
GRID 7 0 0.6 0. 0. 0 345
GRID 8 0 0.7 0. 0. 0 345
GRID 9 0 0.8 0. 0. 0 345
GRID 10 0 0.9 0. 0. 0 345
GRID 11 0 1.0 0. 0. 0 345
$ element definitions
CBAR 1 1 1 2 0. 1. 0.
CBAR 2 1 2 3 0. 1. 0.
CBAR 3 1 3 4 0. 1. 0.
CBAR 4 1 4 5 0. 1. 0.
CBAR 5 1 5 6 0. 1. 0.
CBAR 6 1 6 7 0. 1. 0.
CBAR 7 1 7 8 0. 1. 0.
CBAR 8 1 8 9 0. 1. 0.
CBAR 9 1 9 10 0. 1. 0.
CBAR 10 1 10 11 0. 1. 0.
ENDDATA
===================================
and I would like to find where the grid point definitions start(marked
with $ sign) after that I will take the coordinates into
vectors(hopefully). I guess STL could help me and this way I would also
improve my STL knowledge.

I just wanted some advice before start coding this.

Thank you in advance, regards
 
V

Victor Bazarov

utab said:
assume that I am working with a data file like this
====================================Patran .bdf file for CAE
[..]
$ grid point definitions (HERE STARTS Note parantheses and contents
are not a part of the file!)
GRID 1 0 0.0 0. 0. 0 123456
[..]
===================================
and I would like to find where the grid point definitions start(marked
with $ sign) after that I will take the coordinates into
vectors(hopefully). I guess STL could help me and this way I would
also improve my STL knowledge.

I just wanted some advice before start coding this.

Use 'std::string' and 'std::ifstream' and 'std::getline'. Get a book
on the Standard library, or just study the manual on those three elements
of the library. You're bound to arrive at a solution if you know what
you want.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top