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. Mobile Development
  3. Mobile
  4. problem with fscanf in Pocket PC

problem with fscanf in Pocket PC

Scheduled Pinned Locked Moved Mobile
questionc++performancehelp
4 Posts 2 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.
  • V Offline
    V Offline
    villalbaja
    wrote on last edited by
    #1

    hello,Reading a text file of integers with this code for (k=0;k<256; k++) { for (l=0;l<12; l++) fscanf(fmel,"%d",&melCdb->vq[k][l]); for(l=0;l<12;l++) { fscanf(fmel,"%d",&aux); // melCdb->cov[k][l]=2*aux; } } the program breaks when k=16 without any reason in fscanf(fmel,"%d",&melCdb->vq[k][l]); there is more than 10mb of free memory in the Pocket PC and this code works properly with the same file in in the desktop with VC++ 6.0. Somebody knows what is the problem? Thanks

    D 1 Reply Last reply
    0
    • V villalbaja

      hello,Reading a text file of integers with this code for (k=0;k<256; k++) { for (l=0;l<12; l++) fscanf(fmel,"%d",&melCdb->vq[k][l]); for(l=0;l<12;l++) { fscanf(fmel,"%d",&aux); // melCdb->cov[k][l]=2*aux; } } the program breaks when k=16 without any reason in fscanf(fmel,"%d",&melCdb->vq[k][l]); there is more than 10mb of free memory in the Pocket PC and this code works properly with the same file in in the desktop with VC++ 6.0. Somebody knows what is the problem? Thanks

      D Offline
      D Offline
      Daniel Strigl
      wrote on last edited by
      #2

      Try this:

      ...
      for (l=0;l<12; l++)
      {
      int value;
      fscanf(fmel,"%d",&value);
      melCdb->vq[k][l] = value;
      ...

      If this doesn't help: How do you create the array melCdb->vq[k][l]? Please show us your source code! -- Cheers, Daniel ;)

      V 1 Reply Last reply
      0
      • D Daniel Strigl

        Try this:

        ...
        for (l=0;l<12; l++)
        {
        int value;
        fscanf(fmel,"%d",&value);
        melCdb->vq[k][l] = value;
        ...

        If this doesn't help: How do you create the array melCdb->vq[k][l]? Please show us your source code! -- Cheers, Daniel ;)

        V Offline
        V Offline
        villalbaja
        wrote on last edited by
        #3

        Hello, the source code is melCdb->vq=(long **)malloc((256)*sizeof(long *)); for (k=0;k<256; k++) { melCdb->vq[k]=(long *)malloc((12)*sizeof(long)); } for (k=0;k<256; k++) { for (l=0;l<12; l++) fscanf(fmel,"%d",&melCdb->vq[k][l]); for(l=0;l<12;l++) { fscanf(fmel,"%d",&aux); } } I have already checked that mallocs give dinamic memory correctly. Thanks for your help.

        D 1 Reply Last reply
        0
        • V villalbaja

          Hello, the source code is melCdb->vq=(long **)malloc((256)*sizeof(long *)); for (k=0;k<256; k++) { melCdb->vq[k]=(long *)malloc((12)*sizeof(long)); } for (k=0;k<256; k++) { for (l=0;l<12; l++) fscanf(fmel,"%d",&melCdb->vq[k][l]); for(l=0;l<12;l++) { fscanf(fmel,"%d",&aux); } } I have already checked that mallocs give dinamic memory correctly. Thanks for your help.

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

          Try this:

          for (k=0;k<256;k++)
          {
          for (l=0;l<12;l++)
          {
          long* pl = melCdb->vq[k];
          fscanf(fmel,"%ld",&pl[l]);
          }
          }

          Don't forget to use %ld in the fscanf function, because this are the right syntax for a long. -- Cheers, Daniel ;)

          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