Author Topic: GCC no Debug and fscanf problem  (Read 1218 times)

Offline fopetesl

  • Single posting newcomer
  • *
  • Posts: 8
GCC no Debug and fscanf problem
« on: January 12, 2019, 02:43:29 pm »
I have a binary file begins:
Code
01 C8 01 FD 01 FB 01 F1 01 F3 01 F7 01 F6 01 F1 01 F4 01 FB 01 F4 01 FB 01 FA 01 F6 01 F7 01 F5
i.e. 16 bit integers, so array[0] = 0x1C8

In the past I have used GCC on LINUX and read/write files without any problem, though still a 'C' novice.
So, this compiles without error:
Code
    while((pDirent = readdir(dir)) != NULL) {
//      printf ("[%s]\n", pDirent->d_name);
      if( !strncmp( pDirent->d_name, "baseline.bas",11) ) {
        printf("Found baseline!\n");
      }
    }
    if( Readbase = fopen("baseline.bas","rb") == NULL)
        printf("Open Baseline failed\n");
    else
        printf("Open Baseline success\n");
    _getch();  // so I can see result
    rewind(Readbase);
    ii = i2 = 0;
    while( fscanf( Readbase,"%x",&ii) != -1) {
      printf("%x ",ii);
      basefile[i2++] = ii;
    }
    basefile[i2] = 0;        /* insurance! */
    uDataPoints = i2;
    printf("\nRead %d points\n", uDataPoints);
Output:
Code
 Directory: C:\BIN2CSV\Binary2csv
Open Baseline success

Read 0 points

Process returned 0 (0x0)   execution time : 14.418 s
Press any key to continue.

Almost identical  code from a LINUX compile ran without problem, so I've muffed it somewhere but cannot see how.

Also I set up the project with Debug turned off. How to turn it on?

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13319
    • Travis build status
Re: GCC no Debug and fscanf problem
« Reply #1 on: January 12, 2019, 03:17:32 pm »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline fopetesl

  • Single posting newcomer
  • *
  • Posts: 8
Re: GCC no Debug and fscanf problem
« Reply #2 on: January 12, 2019, 03:24:40 pm »
Yes. I've been there but the option "Debug" isn't available and adding the "-g" option doesn't enable it.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13319
    • Travis build status
Re: GCC no Debug and fscanf problem
« Reply #3 on: January 12, 2019, 07:31:00 pm »
What do you mean by there? Do you have a project? Do you have a debug target in the build options? If you don't have one you should create one...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline fopetesl

  • Single posting newcomer
  • *
  • Posts: 8
Re: GCC no Debug and fscanf problem
« Reply #4 on: January 13, 2019, 09:59:32 am »
I don't know what is bad in my original code but I worked around it using fprintf() :)
I recreated the project but this time included Debug option.
Thanks for the input.