Hot answers tagged

5 votes
Accepted

Help me write sexier code : ) counters as pointers, buffering files, feof, sprintf [pset4.recover]

char would store the ASCII codes for the hexadecimal digits Well, not really! If you do something like unsigned char c = 0xff; // hex this won't store the ASCII value of 255(dec) because 255(dec) ...
user avatar
  • 17.4k
2 votes
Accepted

I keep getting "expected EOF" when I use check50

When the code is run with the test data that check50 uses, 4111111111111113, it prints INVALID twice. check50 was expecting the program to end, not to print the second INVALID. The problem is obvious ...
user avatar
  • 64.1k
1 vote
Accepted

Receiving EOF when I execute check50 (Readability)

I found the mistake was in a space between %i\n and ", in the line printf("Grade %i\n ", (int) round(index)); The problem was solved when rewriting to: printf("Grade %i\n", (...
user avatar
1 vote

helpers.c: EOF not working

Not really sure why this is happening, but the most likely thing that happened is that you've messed up with the main find.c file, as it is, EOF was controlled there itself, so, check to see if it has ...
user avatar
  • 1,146
1 vote
Accepted

Can somebody please help me to better understand constant variables, and eof, and how they relate to pset3?

Constant variables, with const int MAX as an example, the const means that MAX will not be modified. It is constant so it must not, and will not be changed. Some reasons for using a const is; the ...
user avatar
  • 1,223
1 vote

Pset 4 Recover Segmentation Fault

There's a few problems with your code, not sure which one is causing the segmentation fault. 1) Why are you using 2 as the third argument of fread? You're supposed to read 512 bytes at a time, not ...
user avatar
  • 1,677
1 vote
Accepted

EOF command not working

Are you sure that you are correctly interpreting what is happening? It sounds to me like the ctrl-d may well be working just fine, but the code is going into an infinite loop at some later point, but ...
user avatar
  • 64.1k
1 vote
Accepted

pset4 resize premature end of file encountered

I think maybe the relationship between biSize, biSizeImage, and bfSize is not reflected properly in the code. Here's reference from MSDN: bfSize: The size, in bytes, of the bitmap file. ~ MSDN ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible