я борюсь с этой частью кода, что бы я ни пытался, я не могу заставить его читать в запись после двух строк
текстовый файл содержит
Mickey Mouse 12121 Goofy 24680 Andy Capp 01928 Quasi Modo 00041 end
и код
#include<iostream>
#include<string.h>
#include <stdio.h>
#include <windows.h>
#include<iomanip>
#include<conio.h>
#include<fstream>
#include<string>
using namespace std;
struct record
{
char name[20];
int number;
};
void main()
{
record credentials[30];
int row=0;
fstream textfile;//fstream variable
textfile.open("credentials.txt",ios::in);
textfile.getline (credentials[row].name,30);
//begin reading from test file, untill it reads end
while(0!=strcmp(credentials[row].name,"end"))
{
textfile>>credentials[row].number;
row++;
//read next name ....if its "end" loop will stop
textfile.getline (credentials[row].name,30);
}
textfile.close();
}
запись занимает только первые две строчки а остальное пусто есть идеи ??
string
? Кроме того, вы разрешаетеgetline
читать до 30 символов в поле длиной 20 символов. - person Some programmer dude   schedule 21.09.2012