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. Binary to Text File

Binary to Text File

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
14 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
    PremalathaP
    wrote on last edited by
    #1

    How to convert a binary file with extension .LRN to .Txt file in C++? Premalatha

    T K 2 Replies Last reply
    0
    • P PremalathaP

      How to convert a binary file with extension .LRN to .Txt file in C++? Premalatha

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      and what is the .lnr file supposed to contain please ?


      TOXCCT >>> GEII power
      [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

      P K 2 Replies Last reply
      0
      • T toxcct

        and what is the .lnr file supposed to contain please ?


        TOXCCT >>> GEII power
        [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

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

        .LRN file is a binary file which contains some float values of different parameters. Eg: max_ceiling : 47000 plan_area : 516 mach_cr : 0.63 Otherwise just tell me how to convert a binary file into a text file Thanks & Regards, Premalatha

        C T 2 Replies Last reply
        0
        • T toxcct

          and what is the .lnr file supposed to contain please ?


          TOXCCT >>> GEII power
          [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

          K Offline
          K Offline
          kelprinc
          wrote on last edited by
          #4

          I don`t realy understand your question, but from what i understand i suggest you open your file in binary mode and write it to a nuew file with a .txt extension. ifstream infile; infile.open("file_name.lnr", ios::bin); //get the number of characters infile.read(buffer,size); ofstream outfile; outfile.open("new_file.txt"); outfile.write(buffer,size); The syntax might be wrong Kelvin Chikomo

          T 1 Reply Last reply
          0
          • P PremalathaP

            .LRN file is a binary file which contains some float values of different parameters. Eg: max_ceiling : 47000 plan_area : 516 mach_cr : 0.63 Otherwise just tell me how to convert a binary file into a text file Thanks & Regards, Premalatha

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            PremalathaP wrote:

            max_ceiling : 47000 plan_area : 516 mach_cr : 0.63

            For me, this looks not like a binary file. It is simple text format, the only thing is that it doesn't have a txt extension. If that bother you, you can still change the extension manually but I don't think this is a good idea. If you want to open it, you just have to right click on it and choose "open with".

            P 1 Reply Last reply
            0
            • K kelprinc

              I don`t realy understand your question, but from what i understand i suggest you open your file in binary mode and write it to a nuew file with a .txt extension. ifstream infile; infile.open("file_name.lnr", ios::bin); //get the number of characters infile.read(buffer,size); ofstream outfile; outfile.open("new_file.txt"); outfile.write(buffer,size); The syntax might be wrong Kelvin Chikomo

              T Offline
              T Offline
              toxcct
              wrote on last edited by
              #6

              i'm not the owner of the question... missed !;P


              TOXCCT >>> GEII power
              [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

              1 Reply Last reply
              0
              • P PremalathaP

                .LRN file is a binary file which contains some float values of different parameters. Eg: max_ceiling : 47000 plan_area : 516 mach_cr : 0.63 Otherwise just tell me how to convert a binary file into a text file Thanks & Regards, Premalatha

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                this file don't seem to be binary (as we can see plainly with notepad for e.g.)


                TOXCCT >>> GEII power
                [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

                P 1 Reply Last reply
                0
                • C Cedric Moonen

                  PremalathaP wrote:

                  max_ceiling : 47000 plan_area : 516 mach_cr : 0.63

                  For me, this looks not like a binary file. It is simple text format, the only thing is that it doesn't have a txt extension. If that bother you, you can still change the extension manually but I don't think this is a good idea. If you want to open it, you just have to right click on it and choose "open with".

                  P Offline
                  P Offline
                  PremalathaP
                  wrote on last edited by
                  #8

                  Actually this is the text file format of that LRN file. The content of that LRN file is :  ÌÌÌÌÌÌÌÌ SVRGNX05€IN-APM€ ˜7G D®G!? €;E ÈB   # xìÃd*; TˆF `êF TìF zC zC €˜CÍÌL? zC ×#? ŒC @? €˜CÍÌL? @@ ÍÌL? RCÍÌL? HC €˜C zC HC /C þÿF HC 4C C pA þÿF HC 4C C þÿF þÿF  ŒF`å0? 4C @F zC *C ¤p? ¸ÓF   ßà£@€BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK zÅ @œE @F @œF `êF ¸G @G È/G PCGñq?•`q?„Øq?Hmr?ôt?¬Êv?“Æx?—V{?~?IK?›U?è¤?k€?ÍX€?w-?{ˆ‚?†ƒ?ÀÏ„?œm†?Xsˆ?Îü’?t$“?k`“?"«“?€”?rÜ•? Ü–?R'˜?!È™?Ó›?» ? 7 ?s ?¾ ?`“¡?Zð¢?™ð£?2=¥?¤ß¦?>í¨? @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ ÀÚF ÀÚF ÀÚF ÀÚF ÀÚF úÄ úE éF `jG `jG `jG `jG ‡C €˜C €˜CÍÌL?ÍÌL?ÍÌL?ÍÌL? @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ zÄ @œF ¸G   G ˜7G ˜7G ˜7G ˜7G \B \B @A Á ¨Á     X X X ’ ’ ’ ’ ’ ’ ®Ga?®Ga?®Ga?®Ga? ÍÌ,@ €@ìQø¿fff¿ÍÌÌ=oƒ: ÍÌL> ¦›D; ×#< ff–@ @ffŽAš™Àš™Ù?ff¶@ÍÌLÀff†@ )\ï?š™@{®Gázt? {®Gáz„? š™™™™™©? š™™™™™É? Ð? š™™™™™É? š™™™™™©? ü©ñÒMb`? {®Gáz„? Ð? ÿ ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ“ˆ

                  C 1 Reply Last reply
                  0
                  • P PremalathaP

                    How to convert a binary file with extension .LRN to .Txt file in C++? Premalatha

                    K Offline
                    K Offline
                    kelprinc
                    wrote on last edited by
                    #9

                    I don`t realy understand your question, but from what i understand i suggest you open your file in binary mode and write it to a nuew file with a .txt extension. ifstream infile; infile.open("file_name.lnr", ios::bin); //get the number of characters infile.read(buffer,size); ofstream outfile; outfile.open("new_file.txt"); outfile.write(buffer,size); The syntax might be wrong Kelvin Chikomo

                    P 1 Reply Last reply
                    0
                    • T toxcct

                      this file don't seem to be binary (as we can see plainly with notepad for e.g.)


                      TOXCCT >>> GEII power
                      [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

                      P Offline
                      P Offline
                      PremalathaP
                      wrote on last edited by
                      #10

                      Actually this is the text file format of that LRN file. The content of that LRN file is :  ÌÌÌÌÌÌÌÌ SVRGNX05€IN-APM€ ˜7G D®G!? €;E ÈB   # xìÃd*; TˆF `êF TìF zC zC €˜CÍÌL? zC ×#? ŒC @? €˜CÍÌL? @@ ÍÌL? RCÍÌL? HC €˜C zC HC /C þÿF HC 4C C pA þÿF HC 4C C þÿF þÿF ŒF`å0? 4C @F zC *C ¤p? ¸ÓF   ßà£@€BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK zÅ @œE @F @œF `êF ¸G @G È/G PCGñq?•`q?„Øq?Hmr?ôt?¬Êv?“Æx?—V{?~?IK?›U?è¤?k€?ÍX€?w-?{ˆ‚?†ƒ?ÀÏ„?œm†?Xsˆ?Îü’?t$“?k`“?"«“?€”?rÜ•? Ü–?R'˜?!È™?Ó›?» ? 7 ?s ?¾ ?`“¡?Zð¢?™ð£?2=¥?¤ß¦?>í¨? @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ ÀÚF ÀÚF ÀÚF ÀÚF ÀÚF úÄ úE éF `jG `jG `jG `jG ‡C €˜C €˜CÍÌL?ÍÌL?ÍÌL?ÍÌL? @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ zÄ @œF ¸G G ˜7G ˜7G ˜7G ˜7G \B \B @A Á ¨Á     X X X ’ ’ ’ ’ ’ ’ ®Ga?®Ga?®Ga?®Ga? ÍÌ,@ €@ìQø¿fff¿ÍÌÌ=oƒ: ÍÌL> ¦›D; ×#< ff–@ @ffŽAš™Àš™Ù?ff¶@ÍÌLÀff†@ )\ï?š™@{®Gázt? {®Gáz„? š™™™™™©? š™™™™™É? Ð? š™™™™™É? š™™™™™©? ü©ñÒMb`? {®Gáz„? Ð? ÿ ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ“ˆ

                      1 Reply Last reply
                      0
                      • K kelprinc

                        I don`t realy understand your question, but from what i understand i suggest you open your file in binary mode and write it to a nuew file with a .txt extension. ifstream infile; infile.open("file_name.lnr", ios::bin); //get the number of characters infile.read(buffer,size); ofstream outfile; outfile.open("new_file.txt"); outfile.write(buffer,size); The syntax might be wrong Kelvin Chikomo

                        P Offline
                        P Offline
                        PremalathaP
                        wrote on last edited by
                        #11

                        Thanks for ur code i'll try and let u know

                        C N 2 Replies Last reply
                        0
                        • P PremalathaP

                          Actually this is the text file format of that LRN file. The content of that LRN file is :  ÌÌÌÌÌÌÌÌ SVRGNX05€IN-APM€ ˜7G D®G!? €;E ÈB   # xìÃd*; TˆF `êF TìF zC zC €˜CÍÌL? zC ×#? ŒC @? €˜CÍÌL? @@ ÍÌL? RCÍÌL? HC €˜C zC HC /C þÿF HC 4C C pA þÿF HC 4C C þÿF þÿF  ŒF`å0? 4C @F zC *C ¤p? ¸ÓF   ßà£@€BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK €BLANK zÅ @œE @F @œF `êF ¸G @G È/G PCGñq?•`q?„Øq?Hmr?ôt?¬Êv?“Æx?—V{?~?IK?›U?è¤?k€?ÍX€?w-?{ˆ‚?†ƒ?ÀÏ„?œm†?Xsˆ?Îü’?t$“?k`“?"«“?€”?rÜ•? Ü–?R'˜?!È™?Ó›?» ? 7 ?s ?¾ ?`“¡?Zð¢?™ð£?2=¥?¤ß¦?>í¨? @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ ÀÚF ÀÚF ÀÚF ÀÚF ÀÚF úÄ úE éF `jG `jG `jG `jG ‡C €˜C €˜CÍÌL?ÍÌL?ÍÌL?ÍÌL? @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ @œÅ zÄ @œF ¸G   G ˜7G ˜7G ˜7G ˜7G \B \B @A Á ¨Á     X X X ’ ’ ’ ’ ’ ’ ®Ga?®Ga?®Ga?®Ga? ÍÌ,@ €@ìQø¿fff¿ÍÌÌ=oƒ: ÍÌL> ¦›D; ×#< ff–@ @ffŽAš™Àš™Ù?ff¶@ÍÌLÀff†@ )\ï?š™@{®Gázt? {®Gáz„? š™™™™™©? š™™™™™É? Ð? š™™™™™É? š™™™™™©? ü©ñÒMb`? {®Gáz„? Ð? ÿ ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ“ˆ

                          C Offline
                          C Offline
                          Cedric Moonen
                          wrote on last edited by
                          #12

                          Geez, why don't you explain clearly your problem when asking your question ? And, why do you want to change this file into text file ? The only way to do it is to know EXACTLY what is stored in the file, in which order, ... So you'll have to do EXACTLY the same operation as done for creating the file but in the other way (so extract the data). Then when you have extracted all the data, you can print them in another file (with fprintf for example, or using the streams from the STL). But I think you don't know what is the exact file format, am I right ? So, you can't do what you are trying to do. Or, you'll have to search on internet for the descritption of the file format and then load it yourself.

                          1 Reply Last reply
                          0
                          • P PremalathaP

                            Thanks for ur code i'll try and let u know

                            C Offline
                            C Offline
                            Cedric Moonen
                            wrote on last edited by
                            #13

                            That won't work: this will just take everything that is in your file and paste it exactly the same in a text file. So you will be able to open your file directly with notepad but the contents will be exactly the same. There is no way of doing what you want without knowing how the data is stored in the file. That is: they saved first this variable (a float), then this string, then this integer value, ... quite difficult to know without having the sources files of the program itself.

                            1 Reply Last reply
                            0
                            • P PremalathaP

                              Thanks for ur code i'll try and let u know

                              N Offline
                              N Offline
                              namaskaaram
                              wrote on last edited by
                              #14

                              well premlatha,the .lrn file that u have mentioned would follow a structure...... Find out the structure/class..... then read the file thru that object..... then open up an another file and write the the members using text formatted functions like fprintf..... if you were to simply copy the file as it is in binary mode and then write it down in an anoter file ,all u get is a duplicate of the original file! cheerz! rateep "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13

                              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