Link to home
Start Free TrialLog in
Avatar of prain
prainFlag for United States of America

asked on

How to convert a Text File into a byte array in C++

Any one knows how to convert a given text file (unknown size) into a byte array in C++. Please do not answer this in C or C# or Java. I want this in C++.

Thanks
prain
SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of prain

ASKER

Hello jkr,
you meant pAdd and not pArr right? I do not see pAdd is being used anywhere after it is defined.

prain
Actually, it should be
BYTE* pArr = new BYTE[buf.st_size];

Open in new window

Sorry about that.
Avatar of prain

ASKER

More points.
Avatar of prain

ASKER

Ok, with all due respect to sarabande's answer, I accept jrk's because it fits our coding style well.

I have increased the points to 200 and given the increased amount to sarabande, while jrk get full points I promised first.

Thanks guys again.
-prain