---------------
fgetc() reads the next character from stream and returns it as an unsigned char cast to an int, or EOF on end of file or error.
getc() is equivalent to fgetc() except that it may be implemented as a macro which evaluates stream more than once.
getchar() is equivalent to getc(stdin).
---------------
You don't get an EOF unless the stream reaches EOF or errors. The cast to int allows for values outside of 0-255. EOF happens to be value -1 in my libc.
Fail less.
Name:
Anonymous2007-11-21 22:24
Rule 30 cellular automata are only a reasonable choice if their space is unrestricted. By confining them in cyclical space you can reverse them if you get the state somewhere (see http://www.mathpages.com/home/kmath439/kmath439.htm ). Even more seriously, you can get the complete state by a known plaintext attack. Of course you get 8 bits for one known byte, but you can get on average 1.5 bits more for every consecutive byte:
xabcdefghy
.ijklmnop.
You can compute x from the following equation:
i = x^(a|b)
x = i^(a|b)
y can be computed iff h = 0:
p = g^(h|y)
p = g^y
y = p^g
For your 32 bits it would take on average 17 known bytes to fully crack it. Of course 32 bits are way too few to stop someone from bruteforcing it.
>>7
EOF is not a character >>8
No, it returns an int. an int may be 16 or more bits in size. >>9 The cast to int allows for values outside of 0-255.
There's no cast being done to 'int'.
It simply returns int.
If you really want it to be portable to ANY system you have to do:
for(clearerr(stream); (c = fgetc(stream)) != EOF && (ferror(stream) || feof(stream)));)