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. Plz chck this code!!

Plz chck this code!!

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 4 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.
  • U Offline
    U Offline
    User 1878431
    wrote on last edited by
    #1

    Hye. i write this code to get inpur from user such as ram and hard disk capacity as integer type using structures. After that i want to create a file in which i want to save that data. In the code below it is getting input from user but not creating file:confused:. Plz tell where is my mistake. Code is: #include #include #include void main() { struct computerspec { int ram; int hdisk; }compuspec; cout<<"Enter the RAM capacity"<>compuspec.ram; cout<>compuspec.hdisk; cout<

    R D S 3 Replies Last reply
    0
    • U User 1878431

      Hye. i write this code to get inpur from user such as ram and hard disk capacity as integer type using structures. After that i want to create a file in which i want to save that data. In the code below it is getting input from user but not creating file:confused:. Plz tell where is my mistake. Code is: #include #include #include void main() { struct computerspec { int ram; int hdisk; }compuspec; cout<<"Enter the RAM capacity"<>compuspec.ram; cout<>compuspec.hdisk; cout<

      R Offline
      R Offline
      Rahim Rattani
      wrote on last edited by
      #2

      i dont see any problem in your code. It must be working fine and must crate the file. Check the file 1) if you are directly running the .exe, at the location of the exe file. 2) if you are executing from the vc projecy, then the file will be created at the location of workspace and project files i.e. where .dsw/.dsp exists. Rahim Rattani Software Engineer, Matrix Systems (Pvt) Ltd., Karachi - Pakistan

      1 Reply Last reply
      0
      • U User 1878431

        Hye. i write this code to get inpur from user such as ram and hard disk capacity as integer type using structures. After that i want to create a file in which i want to save that data. In the code below it is getting input from user but not creating file:confused:. Plz tell where is my mistake. Code is: #include #include #include void main() { struct computerspec { int ram; int hdisk; }compuspec; cout<<"Enter the RAM capacity"<>compuspec.ram; cout<>compuspec.hdisk; cout<

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        rose aashii wrote: file.open("computerspec.txt"); Does this statement create the file if it does not exist?


        "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

        R 1 Reply Last reply
        0
        • D David Crow

          rose aashii wrote: file.open("computerspec.txt"); Does this statement create the file if it does not exist?


          "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

          R Offline
          R Offline
          Rahim Rattani
          wrote on last edited by
          #4

          Yes it does creates the file, if the file does not exist. The actual syntax is file.open(filename, open flags, protection specifications). The default open flag is ios::out which creates the file if it does not exists. To avoid the file creation if it does not exists another flag ios::nocreate is used. Rahim Rattani Software Engineer, Matrix Systems (Pvt) Ltd., Karachi - Pakistan

          1 Reply Last reply
          0
          • U User 1878431

            Hye. i write this code to get inpur from user such as ram and hard disk capacity as integer type using structures. After that i want to create a file in which i want to save that data. In the code below it is getting input from user but not creating file:confused:. Plz tell where is my mistake. Code is: #include #include #include void main() { struct computerspec { int ram; int hdisk; }compuspec; cout<<"Enter the RAM capacity"<>compuspec.ram; cout<>compuspec.hdisk; cout<

            S Offline
            S Offline
            SuperTank
            wrote on last edited by
            #5

            I´ve done the following changes in your code, and it works just fine for me. #include #include #include using namespace std; struct computerspec { int ram; int hdisk; }compuspec; void main() { cout<<"Enter the RAM capacity"<>compuspec.ram; cout<>compuspec.hdisk; cout<

            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