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. Data types of the values inside a text file ?

Data types of the values inside a text file ?

Scheduled Pinned Locked Moved C / C++ / MFC
iosquestionlounge
3 Posts 3 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.
  • K Offline
    K Offline
    KaKa
    wrote on last edited by
    #1

    Hi, In a text file, are the data types of the values in the file all of the type char or can there be integers inside? I wrote a code which produces random numbers and they are to be written to a text file. int value; ofstream outClientFile("1111 combination.txt",ios::out); value = rand()%2; outClientFile<

    F T 2 Replies Last reply
    0
    • K KaKa

      Hi, In a text file, are the data types of the values in the file all of the type char or can there be integers inside? I wrote a code which produces random numbers and they are to be written to a text file. int value; ofstream outClientFile("1111 combination.txt",ios::out); value = rand()%2; outClientFile<

      F Offline
      F Offline
      fefe wyx
      wrote on last edited by
      #2

      The operator<< of ostream will convert everything it takes to string, and then insert into the stream. So of course the value will be converted to string. If you'd like to write as a integer but not a string, you may use the write() method.

      1 Reply Last reply
      0
      • K KaKa

        Hi, In a text file, are the data types of the values in the file all of the type char or can there be integers inside? I wrote a code which produces random numbers and they are to be written to a text file. int value; ofstream outClientFile("1111 combination.txt",ios::out); value = rand()%2; outClientFile<

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        KaKa' wrote:

        ofstream outClientFile("1111 combination.txt",ios::out); value = rand()%2; outClientFile<

        it upto to you treat data in file... every thing written in file is string or binary digit (in case of binary file, which in turn also a string!)..

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

        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