calling a function within another function

hey guys am trying to call my function to calculate deltaT to trapazoidal function
so that i can use dt in trapazoidal function but its not working......please help....thanx in advance

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <fstream>

using namespace std;
void GetValuesFromFile(vector<int>&YEAR,vector<int>&MONTH,vector<int>&DAY,vector<int>&H,
                                            vector<int>&M,vector<double>&S,vector<double>&VOLTAGE,vector<double>&CURRENT,
                                            vector<double>&FREQUENCEY)
                              {
                                  int year=0, month=0, day=0,hour=0,minutes=0;
                                  double seconds=0,voltage=0,current=0,frequencey=0;

                                  ifstream infile("data.txt");
                                  while(infile>>year>>month>>day
                                            >>hour>>minutes>>seconds
                                            >>voltage>>current>>frequencey)
                                  {
                                      YEAR.push_back(year);
                                      MONTH.push_back(month);
                                      DAY.push_back(day);
                                      H.push_back(hour);
                                      M.push_back(minutes);
                                      S.push_back(seconds);
                                      VOLTAGE.push_back(voltage);
                                      CURRENT.push_back(current);
                                      FREQUENCEY.push_back(frequencey);

                                  }



                              }
    double CalculateDeltaT(vector<int>H,vector<int>M,vector<double>S)


                              {
                                  double time=0;
                                  double dt=0;
                                  vector<double>TIME;
                                  for(int i =0;i<M.size();i++)
                                  {
                                    
                                      time=(H.at(i)*60+M.at(i)*60+S.at(i));

                                      TIME.push_back(time);

                                   }
                                   dt=(TIME.back()-TIME.front())/(TIME.size()-1);


                                  // cout<<dt<<endl;
                                    return dt;
                      }

    double Trapazoidal(vector<int>YEAR,vector<int>MONTH,vector<int>DAY,vector<int>H,
                              vector<int>M,vector<double>S,vector<double>VOLTAGE,vector<double>CURRENT,
                              vector<double>FREQUENCEY,int &k)
                              {
                                  CalculateDeltaT(H,M,S);
                                  double dt=0;
                                  k=dt+5;




                                                           cout<<k<<endl;
                                                           return k;
                              }


int main()
{
                              vector<int>YEAR;
                              vector<int>MONTH;
                              vector<int>DAY;
                              vector<int>H;
                              vector<int>M;
                              vector<double>S;
                              vector<double>VOLTAGE;
                              vector<double>CURRENT;
                              vector<double>FREQUENCEY;
                              vector<double> TIME;
                              int k=0;

                              GetValuesFromFile(YEAR,MONTH,DAY,
                                                               H,M,S,
                                                               VOLTAGE,CURRENT,FREQUENCEY);
                              CalculateDeltaT(H,M,S);
                              CalculateDeltaT(dt);


                                Trapazoidal(YEAR,MONTH,DAY,
                                                           H,M,S,
                                                           VOLTAGE,CURRENT,FREQUENCEY,k);

                                                           return 0;

}
Line 91: Where is dt defined?

CalculateDeltaT returns a value, but you ignore the returned value at line 90.

Did you mean something like this?
1
2
3
4
  double dt;
...
  dt = CalculateDeltaT(H,M,S);
  CalculateDeltaT(dt);




Topic archived. No new replies allowed.