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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to create a .dat file

How to create a .dat file

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

    Does any one know how to create a .dat file. Not just saving a text file by changing the extension. The file should only be opened using specified program and not by other editors. For example,Yahoo messenger archieves are stored in .dat file format. I want to save the data of my application in a safer way. Help please. Thanks

    C D D 3 Replies Last reply
    0
    • P poda

      Does any one know how to create a .dat file. Not just saving a text file by changing the extension. The file should only be opened using specified program and not by other editors. For example,Yahoo messenger archieves are stored in .dat file format. I want to save the data of my application in a safer way. Help please. Thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      poda123 wrote:

      Does any one know how to create a .dat file. Not just saving a text file by changing the extension.

      A .dat file will have it's own file format, which won't be text. You can similarly define any file format that you like. Typically, these will contain metadata to define the values that are coming up, or will be fixed and, for example, store numbers as numbers, instead of as ASCII or Unicode values. Another option is to use compression or encryption to hide your data in your format.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      P 1 Reply Last reply
      0
      • C Christian Graus

        poda123 wrote:

        Does any one know how to create a .dat file. Not just saving a text file by changing the extension.

        A .dat file will have it's own file format, which won't be text. You can similarly define any file format that you like. Typically, these will contain metadata to define the values that are coming up, or will be fixed and, for example, store numbers as numbers, instead of as ASCII or Unicode values. Another option is to use compression or encryption to hide your data in your format.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        P Offline
        P Offline
        poda
        wrote on last edited by
        #3

        That's what really I want. How to define my own file format.

        J 1 Reply Last reply
        0
        • P poda

          Does any one know how to create a .dat file. Not just saving a text file by changing the extension. The file should only be opened using specified program and not by other editors. For example,Yahoo messenger archieves are stored in .dat file format. I want to save the data of my application in a safer way. Help please. Thanks

          D Offline
          D Offline
          Daniel Kanev
          wrote on last edited by
          #4

          There are many different ways. For instance if you want to store point coordinates you can create a structure like this struct Point { double x; double y; }; and store all points you have consequentially in the file. There are different ways of doing that too. The simplest is using FILE* f = fopen("test.dat","bw"); fclose(f);

          P 1 Reply Last reply
          0
          • P poda

            That's what really I want. How to define my own file format.

            J Offline
            J Offline
            Joan M
            wrote on last edited by
            #5

            At first you should think on how do you want to store that data, then serialize that data into a file using a function that encapsulates the way you want to do it. In fact, you could generate a "document" class with a load and save functions. You can make it as complicated as you want by applying encryption methods and others, but you must decide how to do it. In fact if you want to generate some kind of file that only your application must be able to open and understand, you should decide how do you want to store that data without thinking on making it standard in any way. If you want to open that file automatically with your application then register the file extension. Hope this helps.

            https://www.robotecnik.com freelance robots, PLC and CNC programmer.

            1 Reply Last reply
            0
            • P poda

              Does any one know how to create a .dat file. Not just saving a text file by changing the extension. The file should only be opened using specified program and not by other editors. For example,Yahoo messenger archieves are stored in .dat file format. I want to save the data of my application in a safer way. Help please. Thanks

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

              poda123 wrote:

              Does any one know how to create a .dat file.

              In exactly the same way as you would any other file. A file's extension has no bearing on how it is created.

              poda123 wrote:

              The file should only be opened using specified program and not by other editors.

              This is rather difficult, if at all, to achieve.

              poda123 wrote:

              For example,Yahoo messenger archieves are stored in .dat file format.

              But that does not imply that YM could open any .dat file, only those that it created.


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              1 Reply Last reply
              0
              • D Daniel Kanev

                There are many different ways. For instance if you want to store point coordinates you can create a structure like this struct Point { double x; double y; }; and store all points you have consequentially in the file. There are different ways of doing that too. The simplest is using FILE* f = fopen("test.dat","bw"); fclose(f);

                P Offline
                P Offline
                poda
                wrote on last edited by
                #7

                Thanks for suggestions! Thank 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