delete
delete
Last edited by clag; 10-03-2009 at 05:32 PM. Reason: de
You shouldn't be comparing it to null, you should be comparing it to '\0' ... it's not the same thing. Why don't you just use fputs?
Quzah.
Hope is the first step on the road to disappointment.
what should I return if I use fputs...will mine still be valid?
Your function is a void fuction. You can't return anything.
Quzah.
Hope is the first step on the road to disappointment.
delete
Last edited by clag; 10-03-2009 at 05:32 PM. Reason: delete
if I just use fputc, it compiles fine, but is the program erroneous?
Last edited by clag; 10-03-2009 at 12:20 PM.
man fputs:
[code=cpp]int fputs(const char *restrict s, FILE *restrict stream);[/code]
When you do this:
with aCode:message[index]you're passing a character, not a pointer to a character. That's what the compiler is complaining about.Code:const char *message
Any reason you're not just doing
???Code:fprintf(stderr, message);
cause Values of message are expected to be a NULL terminated character arrays.
Just pass message, not one character from it.
Quzah.
Hope is the first step on the road to disappointment.
delete
Last edited by clag; 10-03-2009 at 05:33 PM.
What are you trying to return? I mean, you're passing along a message and a place to write it, but what are you trying to have it return? What do you want your return value to mean or indicate?
Quzah.
Hope is the first step on the road to disappointment.
>but i feel like i'm returning it incorrectly..cuz message[index] would just be message[0] since it exited the loop.
>should i just return message? but that's not long..
Well, this doesn’t make any sense. You cant return long using char *. And why do you expect the index to be 0. Its declared within the function scope and to try to increment in the while loop which is still visible to all those usages in index within the function scope.
Now tell us what you are trying to return from the function?
~ssharish
Life is like riding a bicycle. To keep your balance you must keep moving - Einstein
delete
Last edited by clag; 10-03-2009 at 05:33 PM.
So in this example, your main neither wants nor expects you to return anything; so don't.
So just use fputs like we said a long time ago.Code:void writeline( const char *s, FILE *f ) { if( s && f ) fputs( s, f ); }
Quzah.
Hope is the first step on the road to disappointment.