Is there a way to type cast the first argument of these functions ?
fputs(const *char, FILE *)
fgets(const *char, FILE *)
thanks in advance
Is there a way to type cast the first argument of these functions ?
fputs(const *char, FILE *)
fgets(const *char, FILE *)
thanks in advance
I'm not sure exactly what you are asking but I'll give it a go anyway. You can do this:
But it is more likely in the real world that you would be doing something more like this:Code:int break_your_program; fgets((char *)&break_your_program, stdin); //or something similar to this
However, I still would question why someone would even do the second one.Code:long could_break_your_program = ('%' << 24) | ('l' << 16) | ('d' << 8); fgets((char *)&could_break_your_program, stdin);
1.) Type cast to what? If another 'const' type, it's fine.
2.) I doubt fgets()'s first argument is of the type specified [Talking about the standard stdio.h - fgets()]
fgets has 3 parameters as well
char *fgets(char *s, size_t n, FILE *stream);
All the const means in the fputs case is that it tells you that fputs will not modify what you pass to it. It does not mean that what you pass to it has to be const in the first place