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. C++ File

C++ File

Scheduled Pinned Locked Moved C / C++ / MFC
c++
7 Posts 6 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.
  • M Offline
    M Offline
    Member 8747425
    wrote on last edited by
    #1

    Hi, I have one text file which stores the hex values in different lines(APDU.txt). Eg; 02 01 00 BE 10 04 0E 08 00 06 10 00 2B 61 29 A1 09 06 07 And I need to process this line by line. Here is a sample code that m used so far; FILE *myFile = fopen("D:\\APDU.txt", "rb"); BYTE *buffer,*buffer1; int lengthFile=0; char temp[3]; if(myFile!=NULL) { fseek(myFile,0,SEEK_END); lengthFile=ftell(myFile); fseek(myFile,0,SEEK_SET); buffer=new BYTE[lengthFile+1]; memset(buffer,0,lengthFile+1); fread(buffer,sizeof(BYTE),lengthFile,myFile); fclose(myFile); } buffer1=new BYTE[lengthFile/2]; memset(buffer1,0,lengthFile/2); memset(temp,0,sizeof(temp)); for(int i=0,j=0;i

    L L C D 4 Replies Last reply
    0
    • M Member 8747425

      Hi, I have one text file which stores the hex values in different lines(APDU.txt). Eg; 02 01 00 BE 10 04 0E 08 00 06 10 00 2B 61 29 A1 09 06 07 And I need to process this line by line. Here is a sample code that m used so far; FILE *myFile = fopen("D:\\APDU.txt", "rb"); BYTE *buffer,*buffer1; int lengthFile=0; char temp[3]; if(myFile!=NULL) { fseek(myFile,0,SEEK_END); lengthFile=ftell(myFile); fseek(myFile,0,SEEK_SET); buffer=new BYTE[lengthFile+1]; memset(buffer,0,lengthFile+1); fread(buffer,sizeof(BYTE),lengthFile,myFile); fclose(myFile); } buffer1=new BYTE[lengthFile/2]; memset(buffer1,0,lengthFile/2); memset(temp,0,sizeof(temp)); for(int i=0,j=0;i

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Do you have some sort of a question?

      Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

      1 Reply Last reply
      0
      • M Member 8747425

        Hi, I have one text file which stores the hex values in different lines(APDU.txt). Eg; 02 01 00 BE 10 04 0E 08 00 06 10 00 2B 61 29 A1 09 06 07 And I need to process this line by line. Here is a sample code that m used so far; FILE *myFile = fopen("D:\\APDU.txt", "rb"); BYTE *buffer,*buffer1; int lengthFile=0; char temp[3]; if(myFile!=NULL) { fseek(myFile,0,SEEK_END); lengthFile=ftell(myFile); fseek(myFile,0,SEEK_SET); buffer=new BYTE[lengthFile+1]; memset(buffer,0,lengthFile+1); fread(buffer,sizeof(BYTE),lengthFile,myFile); fclose(myFile); } buffer1=new BYTE[lengthFile/2]; memset(buffer1,0,lengthFile/2); memset(temp,0,sizeof(temp)); for(int i=0,j=0;i

        L Offline
        L Offline
        Lakamraju Raghuram
        wrote on last edited by
        #3

        are you giving us the code ..... or you forgot the question

        1 Reply Last reply
        0
        • M Member 8747425

          Hi, I have one text file which stores the hex values in different lines(APDU.txt). Eg; 02 01 00 BE 10 04 0E 08 00 06 10 00 2B 61 29 A1 09 06 07 And I need to process this line by line. Here is a sample code that m used so far; FILE *myFile = fopen("D:\\APDU.txt", "rb"); BYTE *buffer,*buffer1; int lengthFile=0; char temp[3]; if(myFile!=NULL) { fseek(myFile,0,SEEK_END); lengthFile=ftell(myFile); fseek(myFile,0,SEEK_SET); buffer=new BYTE[lengthFile+1]; memset(buffer,0,lengthFile+1); fread(buffer,sizeof(BYTE),lengthFile,myFile); fclose(myFile); } buffer1=new BYTE[lengthFile/2]; memset(buffer1,0,lengthFile/2); memset(temp,0,sizeof(temp)); for(int i=0,j=0;i

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          fscanf[^].

          Veni, vidi, vici.

          N 1 Reply Last reply
          0
          • C CPallini

            fscanf[^].

            Veni, vidi, vici.

            N Offline
            N Offline
            Nelek
            wrote on last edited by
            #5

            or liquid nitrogen ;P

            Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.

            C 1 Reply Last reply
            0
            • M Member 8747425

              Hi, I have one text file which stores the hex values in different lines(APDU.txt). Eg; 02 01 00 BE 10 04 0E 08 00 06 10 00 2B 61 29 A1 09 06 07 And I need to process this line by line. Here is a sample code that m used so far; FILE *myFile = fopen("D:\\APDU.txt", "rb"); BYTE *buffer,*buffer1; int lengthFile=0; char temp[3]; if(myFile!=NULL) { fseek(myFile,0,SEEK_END); lengthFile=ftell(myFile); fseek(myFile,0,SEEK_SET); buffer=new BYTE[lengthFile+1]; memset(buffer,0,lengthFile+1); fread(buffer,sizeof(BYTE),lengthFile,myFile); fclose(myFile); } buffer1=new BYTE[lengthFile/2]; memset(buffer1,0,lengthFile/2); memset(temp,0,sizeof(temp)); for(int i=0,j=0;i

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

              Member 8747425 wrote:

              memset(buffer,0,lengthFile+1);

              Since buffer has not been properly initialized, what are you expecting this to do?

              Member 8747425 wrote:

              for(int i=0,j=0;i

              Did you fail to notice your incomplete for() loop?

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

              1 Reply Last reply
              0
              • N Nelek

                or liquid nitrogen ;P

                Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                42. :-D

                Veni, vidi, vici.

                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