Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Struct Question

Struct Question

Scheduled Pinned Locked Moved C / C++ / MFC
questionloungec++ios
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Loli10
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • L 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

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      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

      Smaller Animals Software

      L 1 Reply Last reply
      0
      • C Chris Losinger

        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

        Smaller Animals Software

        L Offline
        L Offline
        Loli10
        wrote on last edited by
        #3

        Thanks! Loli10

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups