hi i want to loop through an array and need to get its length, ie. the number of elements stored inside. however, the compiler doesnt like num.length(); it says:
request for members 'length' in 'num', which is of non-aggregate type 'double[10]'.
i have no idea what this means. if anyone could give me some help or tell me of an alternate way, it would be greatly appreciated.
thanks in advance.
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[]){
char buffer[255];
ifstream input(argv[1]);
double num[100];
int i = 0;
double early = 0;
double late = 0;
int length = num.length(); //doesnt work!!!
while(!input.eof()){
input.getline(buffer, 100);
num = atof(buffer);
cout<<num<<endl;
i++;
}
}
request for members 'length' in 'num', which is of non-aggregate type 'double[10]'.
i have no idea what this means. if anyone could give me some help or tell me of an alternate way, it would be greatly appreciated.
thanks in advance.
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[]){
char buffer[255];
ifstream input(argv[1]);
double num[100];
int i = 0;
double early = 0;
double late = 0;
int length = num.length(); //doesnt work!!!
while(!input.eof()){
input.getline(buffer, 100);
num = atof(buffer);
cout<<num<<endl;
i++;
}
}