User forums > Using Code::Blocks
GCC no Debug and fscanf problem
(1/1)
fopetesl:
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
--- End code ---
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);
--- End code ---
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.
--- End code ---
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:
--- Quote from: fopetesl on January 12, 2019, 02:43:29 pm ---Also I set up the project with Debug turned off. How to turn it on?
--- End quote ---
http://wiki.codeblocks.org/index.php/Debugging_with_Code::Blocks
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...
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.
Navigation
[0] Message Index
Go to full version