خرید بک لینک

سلام
در این کد چرا seekg رو مینویسم ,کامپایلر اشتباه میگیره؟

// pr48.cpp : Defines the entry point for the console application.
//

#include"stdafx.h"
#include<iostream>
#include<conio.h>
#include<fstream>
#include<stdlib.h>
using namespace std;
struct student
{
int code;
char name[20];
}st;
char filename[20];
void cls();
void filename2();
void write();
void wrritefile();
void print();
fstream p;
int main()
{
int a;
while (1)
{
cout << "n1=enter filename adress";
cout << "n2=write in file";
cout << "n3=print from file";
cout << "n4=exit";
cin >> a;
cls();
switch (a)
{
case 1:filename2();
break;
case 2:wrritefile();
break;
case 3:print();
break;
case 4:exit(0);
break;
}
}

_getch();
retu 0;
}

//======================================
void cls()
{
system("cls");
}
//======================================
void filename2()
{
cin >> filename;
p.open(filename ,ios::app);
p.close();
}
//===================================
void write()
{
cout << "code= ";
cin >> st.code;
cout << "name= ";
cin >> st.name;
}
//====================================
void wrritefile()
{
write();
p.open(filename, ios::in|ios::out|ios::binary);
p.seekp(sizeof(struct student)*st.code , ios::beg);
p.write((char *)&st ,sizeof(struct student));
p.close();
}
//=============================
void print()
{
student temp;
p.open(filename, ios::in | ios::out | ios::binary);
p.seekg(sizeof(struct student)*temp.code ,ios::beg);
p.read((char *)&temp, sizeof(struct student));

while (!p.eof())
{
if (temp.code != 0)

cout << temp.code << " : " << temp.name << endl;

p.read((char *)&temp, sizeof(struct student));

}
p.close();
}

- - , .

برچسب: نویسنده: محمد رضا جوادیان تاريخ: يکشنبه 9 اسفند 1394 ساعت: 20:22

صفحه بندی