Struct Question
-
Consider the following file in a C++ program: fstream employees(ios::in|ios::out|ios::binary); This file is going to be a random access file in the program. The user will be allowed to read and write records. Records are based upon the following struct: struct emp { int empId; char empName[20]; long empSalary; chat smpDept[4]; } The question is as follows: Is the file required to be a binary file, or can the ios::binary clause be omitted? Can anyone explain this to me? Loli10
-
Consider the following file in a C++ program: fstream employees(ios::in|ios::out|ios::binary); This file is going to be a random access file in the program. The user will be allowed to read and write records. Records are based upon the following struct: struct emp { int empId; char empName[20]; long empSalary; chat smpDept[4]; } The question is as follows: Is the file required to be a binary file, or can the ios::binary clause be omitted? Can anyone explain this to me? Loli10
unless you're converting that long to text when you output, then yes, the file has to be binary. otherwise, you will end up with a bunch of unprintable characters. -c
Civilization is the limitless multiplication of unnecessary necessities. Mark Twain
-
unless you're converting that long to text when you output, then yes, the file has to be binary. otherwise, you will end up with a bunch of unprintable characters. -c
Civilization is the limitless multiplication of unnecessary necessities. Mark Twain