Reading a data file in C++

Reading a data file in C++

I’m trying to read a data file that I can read just find in Visual Basic, but the integers don’t seem to work when I use Visual C++. Note: I am new to C++

example recordstruct DEPTRECORD   {   int DeptID;   char DeptName[25]   };DEPTRECORD DeptRec…….ifstream is( filename, ios::nocreate );……*) &DeptRec, sizeof(DeptRec))cout I’ve tried it in binary and text modes and theresult is always wrong.

Note: the sizeof(DeptRec) is correct when Iuse char DeptID[2] instead of int DeptID in thestructure.

I have been trying this for days what am I doing wrong?

I can’t be certain this is your problem but, if you are using 32-bit Windows, you should note that integers (int) are 4 bytes in C/C++ while integers are still 2 bytes in VB.


Share the Post: