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 << DeptRec.DeptID
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:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular