I have a series of integers in a text file that I need to import and store in ‘int’ and ‘float’ variable. So far I have been able to import these values as std::string variables but need to convert them and don’t know how. if this is a lame question I am new to c++ and would appreciate any help that you can give me.
// Declare the necessary variables.
std::string line;
// Define a file object.
std::ifstream fileInput("C:/2dTrussMaterials.txt");
// std::string material[3];
// int matQuery = 0;
// // Read in all data.
// while (std::getline(fileInput, line, '|')) { // Reads in a quote.
//
// // Print the quote.
// std::cout << line << "
- ";
//
// // Get and print the speaker.
// std::getline(fileInput, material[matQuery]);
// std::cout << line << "
";
//
// matQuery = matQuery+1;
//
// } // End of WHILE.
//
// // Close the stream.
// fileInput.close();
//
// //E modulus of elasticity
// int e = material[0];
//
// //A area of section
// float a = material[1];