
24.02.2008, 19:55
|
|
Познающий
Регистрация: 14.06.2006
Сообщений: 30
Провел на форуме: 170323
Репутация:
11
|
|
Код:
#include <iostream.h>
#include <fstream.h>
struct MYSTRUCT {
char city[20];
char otp[5];
int number;
char r[5];
int mest;
};
int main(void){
int i;
struct MYSTRUCT s[200];
ofstream mystream_out("aeroflot.txt", ios::in|ios::out);
if (!mystream_out)
{
cout << "Cannot open file.\n";
return 1;
}
else{
for(i=1; i<=2; i++){
cout<< "\nZapus" <<("%2.d",i);
cout<< ("\nCity"); cin >> s[i].city;
}
mystream_out.write((char*)s, sizeof(s));
mystream_out<< &s <<endl;
mystream_out.close();
}
return 0;
}
чуствую что гдето ошибся ибо открыв файл получаю вместо двух слов много сиволов разных.
Это так и должно быть или я всётаки ошибся?
Последний раз редактировалось ph0en1x; 24.02.2008 в 19:59..
|
|
|