[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fwrite with GCC
Hi everyone,
just a keep message/warning maybe even a bug with the GCC library.
Background:
I was updating my GEM Mail reader for KGMD and ran into a small problem.
I open'ed a file for writing (binary mode) - everything OK.
I then tried to write to the file with fwrite:
fwrite(fp,"fred",sizeof(char),strlen("fred")) - arguments maybe wrong
order I always have to look them up.
With memprot on this called a bus error.
unfortunately I originally didn't have mem prot on and the filesystem
(minix) started in a loop trashing my disk as it went - luckily I stop it in
time with the reset button.
I tracked the problem down to strlen("fred")-1 as I wanted 4 and not 5.
Now the question:- Why did Minix file system driver start to trash my disk
and why couldn't I write a zero character to the file.
Another question (maybe slightly out of scope):
I was trying to use G++ map template.
I would liked to have used it with the syntax of : map<int,int> ...
The books say this is alright and the default < will be used.
Unfortunately it wouldn't compile without defining a less than operator for
the map:
map<int,int,int_less> ...
Is this a problem with our implementation i.e. old headers etc. or with G++
not quite got there yet.
Thanks in advance Andrew.
PS Where shall I send GemMail reader.