jong-hyun Yeo jong-hyun Yeo - 1 month ago 17
C++ Question

How to read text file in C++ with 4 character?

I have following text file.


And I have to read text file in c++ with divide four character.

and I want insert the four length character into string in one array.

For example,
aaaa, BBBB cccc, DDDD, kkk, each word divided into array.
string WordArray[N][M]

WordArray[0][0] = "aaaa";
WordArray[0][1] = "BBBB";
WordArray[0][2] = "cccc";
WordArray[0][3] = "DDDD";
WordArray[0][4] = "KKK";

WordArray[1][0] = "EEEE";
WordArray[1][1] = "PPPP";
WordArray[1][2] = "MMMM";
WordArray[1][3] = "ssss";
WordArray[1][4] = "PPPP";

WordArray[4][0] = "DDDD";
WordArray[4][1] = "CCCC";

How can I read text in upper way?

I want to use


Take a look at

You could treat each block as 4 characters. Anyway you haven't specified even type of WordArray, so I assume it is flexy ( might be changed)