[prog] Another elementary 'C' question

David Sumbler david at aeolia.co.uk
Tue Dec 14 08:56:12 EST 2004


Could somebody explain the significance of 'const' in C function
prototypes to me, please?  I'm slightly confused.

fprintf, for instance, is shown as

int fprintf(FILE *stream, const char *format, ...)

Now, I imagine that the 'const' there means that fprintf won't change
the contents of the string *format.

But presumably it doesn't change the value pointed to by 'stream'
either, otherwise we'd get in a right old mess with subsequent actions
on the relevant file.  But FILE isn't shown as 'const'.

So have I misunderstood something about 'const' in this sort of
context?

Or is it that the type 'FILE' itself is defined as a constant?

Or what?

David

-- 


More information about the Programming mailing list