Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Problem with C fwrite

Name: Anonymous 2007-11-08 12:51

What the fuck? Why, when I try to write a string to a text file using C, does it change the first character to "ÿ"?

e.g.

ÿ10
ÿhis
ÿololol
ÿhis

(all input on different runs of the program).

I'm using "a+" if that makes any difference, though I've tried with "r+" aswell and that does the same thing.

Any help?

Name: Anonymous 2007-11-09 6:19

>>32
"There is at least one DSP I have worked with where CHAR_BIT is 32. The char types, short, int and long are all 32 bits." - From http://home.att.net/~jackklein/c/inttypes.html

Excellent resource, well worth the 15 it took me to find it again.

Name: Anonymous 2007-11-09 6:23

>>32
THAT'S WHAT THE FUCKING STANDARD SAYS YOU FUCKING MORON PIECE OF SHIT
AND YES, TEHRE ARE PLATFORMS WHERE CHAR_BIT == 64 (or even, CHAR_BIT >= 16)
SO GTRFO YOU FUCKING PIECE OF SHIT LAMER FMOTHERUCKER GOFFUCKIGN MOTEHRUCEKR

/* long long in c99 */
sizeof (char) <= sizeof (short) <= sizeof (int) <= sizeof (long) <= sizeof (long long)


So to end this bullshit with C's char:
- a char is a C byte.
- a char is the smallest addressable word in C.
- a char can be 8 or more bits in size.
- whether a plain char is signed or unsigned depends from your compiler, if CHAR_MIN == 0 then plain char is unsigned, else signed.
- a signed char is guaranteed to hold SCHAR_MIN to SCHAR_MAX
- SCHAR_MIN <= -127
- SCHAR_MAX >= 127


And that sizeof(size_t) is the size of a word on the system, and also equal to sizeof(void*).
Incorrect.
size_t is an unsigned integral type.
sizeof (void *) == sizeof (size_t) is utter nonsense.

What size_t is guaranteed to hold is the size of an object.
e.g. you can never have sizeof obj > SIZE_MAX or char buf[SIZE_MAX + 1];

Just get a copy of the standard.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List