Home > Back-end >  To ask the TXT content is copied to the structure
To ask the TXT content is copied to the structure

Time:12-30

Struct GetCdkey
{
Char * KeyNum=0;
};
# endif

Struct GetCdkey StuAddr [16].//define structure


Ifstream infile (" D: \ \ 123. TXT ");//open the
in the form of outputWhile (! Infile. Eof ())
{
Infile. Getline (STR., 256, '\ n');
Num++;
StuAddr [r]. Num KeyNum=STR;//transferred to structure
}
My TXT content is
1
2
3
4
5
6
7
8
To achieve the effect of is
StuAddr [1]. KeyNum=1
StuAddr [2]. KeyNum=2
StuAddr [3]. KeyNum=3
StuAddr [4]. KeyNum=4
StuAddr [5]. KeyNum=5
StuAddr [6]. KeyNum=6
StuAddr [7]. KeyNum=7
StuAddr [8]. KeyNum=8

Eventually found printed effect into
StuAddr [1]. KeyNum=8
StuAddr [2]. KeyNum=8
StuAddr [3]. KeyNum=8
StuAddr [4]. KeyNum=8
StuAddr [5]. KeyNum=8
StuAddr [6]. KeyNum=8
StuAddr [7]. KeyNum=8
StuAddr [8]. KeyNum=8

Is it my writing is there a problem?

  • Related