print to screen vector

I have read in a file called thickness.txt and assigned the columns of the file as vectors (latitudes_iso, longitudes_iso, depth_iso). I want to check that all data in the file thickness.txt is being read in. How can I print the information in latitudes_iso, longitudes_iso, and depth_iso to the screen?

Thank you.

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
      class LithosphereIsotherm : public Interface<dim>
      {
      public:

        /**
         * Return the initial temperature as a function of position.
         */
        virtual
        double
        initial_temperature(const Point<dim> &position) const;

        /**
         * Declare the parameters this class takes through input files.
         * The default implementation of this function does not describe
         * any parameters. Consequently, derived classes do not have to
         * overload this function if they do not take any runtime parameters.
         */
        static
        void
        declare_parameters(ParameterHandler &prm);

        /**
         * Read the parameters this class declares from the parameter
         * file. The default implementation of this function does not read
         * any parameters. Consequently, derived classes do not have to
         * overload this function if they do not take any runtime parameters.
         */
        virtual
        void
        parse_parameters(ParameterHandler &prm);

      private:

        /**
         * Return the depth at which the temperature is 1673.15 K as a function of position.
         */
        double
        get_lithosphere_isotherm(const double latitude,
            const double longitude) const;

        /**
         * Read and access depth to isotherm file thickness.txt
         */
        std::vector<double> latitudes_iso;
        std::vector<double> longitudes_iso;
        std::vector<double> depths_iso;
      };
You can simply use an instruction of repetition, looping through each position of the vector and 'cout' to print on the screen.

1
2
3
4
5
6
7
8
9
10
11
12
...
std::vector<double> latitudes_iso;
    
    latitudes_iso.push_back(2.4);
    latitudes_iso.push_back(.4);
    latitudes_iso.push_back(3.44);


    int sz = latitudes_iso.size(), i;
    for ( i =0; i < sz; i++ )        
         std::cout<< latitudes_iso[i] <<std::endl;
...


regards
@cronopio
Topic archived. No new replies allowed.