thndrr, По одному в строке элементарно.
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| #include <iostream>
#include <fstream>
#include <vector>
#include <string>
int main()
{
std::vector<int> Vec;
std::string FileName;
std::cout<<"Enter file name\n";
std::getline(std::cin, FileName);
std::ifstream ifs(FileName.c_str());
if(!ifs)
{
std::cerr<<"Can` t open file "<< FileName <<'\n';
return 1;
}
int t=0;
while(!ifs.eof())
{
ifs>>t;
Vec.push_back(t);
}
for(std::vector<int>::const_iterator It=Vec.begin();
It!=Vec.end();
++It)
{
std::cout<<*It<<'\n';
}
return 0;
} |
|
Если с разными символами - стоит считывать строку и разбивать ее по токенам.