H
H
Han4o2017-09-26 22:25:24
Data Structures
Han4o, 2017-09-26 22:25:24

Problem with typing into structs from C++ file?

#include
#include
#include
#include
using namespace std;
struct Dog
{
char Poroda;
char Klichka;
int Vozrast;
};
int main(int argc, char* argv[])
{
setlocale(LC_ALL, "rus");
Sobaka *ps = new Sobaka;
ifstream in("Dannie.txt");
if (!in.is_open())
cout <<"File is not open!";
else
{
while(in!=0)
in.get((*ps).Poroda);
in.close();
}
cout << (*ps). Poroda << endl;
getch();
return 0;
The task is to have the program read the input from the file into heap memory through new, and then send the data to the structure. The problem is that it reads only one character, and through getline gives me an error that I do not understand. Thanks in advance for your help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question