Help with reading from a file

I need to read the values from this file and save only the numerical ones in a new file. How can I skip the header which is up to end_header word? how can read each value and save it
Please help me
This is the format of the file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
ply
format ascii 1.0
obj_info is_cyberware_data 1
obj_info is_mesh 0
obj_info is_warped 0
obj_info is_interlaced 1
obj_info num_cols 512
obj_info num_rows 400
obj_info echo_rgb_offset_x 0.013000
obj_info echo_rgb_offset_y 0.153600
obj_info echo_rgb_offset_z 0.172000
obj_info echo_rgb_frontfocus 0.930000
obj_info echo_rgb_backfocus 0.012660
obj_info echo_rgb_pixelsize 0.000010
obj_info echo_rgb_centerpixel 232
obj_info echo_frames 512
obj_info echo_lgincr 0.000500
element vertex 40256
property float x
property float y
property float z
element range_grid 204800
property list uchar int vertex_indices
end_header
-0.06325 0.0359793 0.0420873 
-0.06275 0.0360343 0.0425949 
-0.0645 0.0365101 0.0404362 
-0.064 0.0366195 0.0414512 
-0.0635 0.0367289 0.0424662 
-0.063 0.0367836 0.0429737 
-0.0625 0.0368247 0.0433543 
-0.062 0.0368657 0.0437349 
-0.0615 0.0369067 0.0441155 
-0.061 0.0369614 0.044623 
-0.0605 0.0370162 0.0451305 
-0.06 0.0370572 0.0455111 
-0.0595 0.0370845 0.0457648 
-0.059 0.0371256 0.0461455 
-0.0585 0.0371529 0.0463992 
-0.058 0.0371666 0.0465261 
-0.0575 0.0371666 0.0465261 
-0.057 0.0371666 0.0465261 
-0.0565 0.0371803 0.046653 
-0.056 0.0371803 0.046653 
-0.0555 0.0371803 0.046653 
-0.055 0.037194 0.0467798 
-0.0545 0.0371666 0.0465261 
-0.054 0.037194 0.0467798 
-0.0535 0.0371803 0.046653 
-0.053 0.037194 0.0467798 
-0.0525 0.0371803 0.046653 
Couldn't you just read the file in line after line until you get a line that says "end_header" and nothing else? From there, reading in floats/doubles is easy.

Also, do you know how to use ifstreams? If not, here's a link:
http://cplusplus.com/doc/tutorial/files/

Good luck!

-Albatross
Thank you very much for the reply. I have written this code but I dont know how to get values of x, y and z only. I mean the numbers then save them into a file. Can u plz check my code below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>

int main () {
  char buffer[256];
 
  ifstream examplefile ("test.txt");
 
  if (! examplefile.is_open())
  { 
     cout << "Error opening file"; 
     exit (1); 
  }

  while (! examplefile.eof() )
  {
    examplefile.getline (buffer,100);
   if (buffer!="end_header");
//read x, y and z 

  }
  return 0;
}
Topic archived. No new replies allowed.