Hỏi đáp
Chia sẻ kiến thức, cùng nhau phát triển
em mới học về file và list khi viết code thì bị lổi
Error C2039 'tu': is not a member of 'std::_List_iterator<std::_List_val<std::_List_simple_types<PhanSo>>>
em mới học về file và list khi viết code thì bị lổi
Error C2039 'tu': is not a member of 'std::_List_iterator<std::_List_val<std::_List_simple_types<PhanSo>>>
#include<fstream>
#include<iostream>
#include<list>
using namespace std;
struct PhanSo
{
int tu, mau;
};
void DocMangPS(char *filename, list<PhanSo> &a);
void GhiMangPS(char *filename, list<PhanSo> a);
void main()
{
list<PhanSo> a;
DocMangPS("input.txt", a);
GhiMangPS("output.txt", a);
}
void DocMangPS(char *filename, list<PhanSo> &a)
{
ifstream fin;
fin.open(filename);
if (fin.is_open() == false)
{
cout << "Ko the doc file " << filename << endl;
}
else
{
int n;
fin >> n;
for (int i = 0; i<n; i++)
{
PhanSo p;
fin >> p.tu;
fin >> p.mau;
a.push_back(p);
}
fin.close();
}
}
void GhiMangPS(char *filename, list<PhanSo> a)
{
ofstream fout;
fout.open(filename);
if (fout.is_open() == false)
{
cout << "Ko the ghi file " << filename << endl;
}
else
{
fout << a.size() << endl;
for (list<PhanSo>::iterator it = a.begin(); it != a.end(); it++)
{
fout << *it.tu << endl;
fout << *it.mau << endl;
}
fout.close();
}
}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
Để sử dụng tính năng này, Bạn cần đăng nhập bằng tài khoản Howkteam.
Đăng nhập
Để xem được nội dung và giúp Kteam duy trì hoạt động.
Bạn vui lòng tắt Adblock trên website howkteam.vn nhé!
Bạn gì ấy đọc chơi
P/S ai đẹp trai/ đẹp gái đọc xong chỉ tui làm con trỏ. đưa thẳng list<> vào trong hàm được không