My code
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <sstream>
#include <cmath>
#define PI 3.14159265
int main(){
std::ifstream ifs("MFSO7.dat");
std::string line;
std::vector<float> column1;
std::vector<float> column2;
std::vector<float> column3;
std::vector<float> vkos;
std::vector<float> vsin;
while(std::getline(ifs, line)) // read one line from ifs
{
std::istringstream iss(line); // access line as a stream
float item1;
float item2;
float item3;
// Read the items from the line
iss >> item1 >> item2 >> item3;
// Add them to the columns.
column1.push_back(item1);
column2.push_back(item2);
column3.push_back(item3);
}
for(int i=0;i<38;i++)
{
vkos[i]=cos(column3[i]* PI/180.0 );
vsin[i]=sin(column3[i]* PI/180.0 );
}
std::cout << vkos[1] << std::endl;
}
Whem I execute the code I got
milenko@milenko-X58-USB3:~/Calibration Files$ ./a1
Segmentation fault (core dumped)
Why?May be I should avoid the loop or...?