News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

GCC no Debug and fscanf problem

Started by fopetesl, January 12, 2019, 02:43:29 PM

Previous topic - Next topic

fopetesl

I have a binary file begins:
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:
    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:
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?

oBFusCATed

(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!]

fopetesl

Yes. I've been there but the option "Debug" isn't available and adding the "-g" option doesn't enable it.

oBFusCATed

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!]

fopetesl

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.