I have a slight problem with my code and think I am missing out on something or don't understand.
Here is my code that basically reads the data from a .txt file and assigning the array to a float. In another .cpp, I want to have this array assigned to another variable but there error is always showing up:
TxtToArrayV2.cpp:
#include<iostream>
#include<fstream>
#include<string>
#include "TxtToArrayV2.h"
using namespace std;
// This program read the data from two files and extract the char data from it being after converted into a float number.
int main()
{
ifstream foutRPM;
ifstream foutTorque;
foutRPM.open("rpmIRLBerlin.txt");
foutTorque.open("torqueIRLBerlin.txt");
char valueRPM[1000];
char valueTorque[1000];
while (!foutRPM.eof() & !foutTorque.eof())
{
foutRPM.getline(valueRPM, 10000);
foutTorque.getline(valueTorque, 10000);
// conversion from char to float: more info on https://www.programiz.com/cpp-programming/string-float-conversion
float RPM = stof(valueRPM);
float Torque_Nm = stof(valueTorque);
cout << RPM << "\n";
cout << Torque_Nm << "\n";
}
foutRPM.close();
foutTorque.close();
system("pause");
return 0;
}
TxtToArrayV2.h
#ifndef __TXT_TO_ARRAY_V2_H__
#define __TXT_TO_ARRAY_V2_H__
extern float RPM;
extern float Torque_Nm;
#endif
source.cpp:
#include "TxtToArrayV2.h"
#include<iostream>
#include<fstream>
#include<string>
void SomeFunctio()
{
double lala = RPM;
}