#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
int main()
{
std::string line;
std::ifstream inFile("input.txt");
int arr[120] = {0}; //you can choose size according to your needs
if(inFile)
{
int i = 0;//this variable will be used to add element into the array
int count = 0;
while(getline(inFile, line, '\n'))
{
std::istringstream s(line);
while(s >> i || !s.eof()) {
if(s.fail())
{
s.clear();
std::string temp;
s >> temp;
continue;
}
else
{
arr[count] = i;
++count;
}
}
}
}
else
{
std::cout<<"file could not be read"<<std::endl;
}
inFile.close();
for(int i: arr)
{
std::cout<<"elem: "<<i<<std::endl;
}
return 0;
}
1 2 4 5 654 64
35 345 537 546 34
r 4 ty 435