>>Yes but how do I change that?
>I would think it would be obvious:
Seriously? I just started messing with C a few days ago. I've only ever programmed in Perl and Python. The example you provided works but I still have no idea why... I'll continue to research it, but I thought the point of this board was to get help with things, not get cryptic responses that provide more questions than I started with.
So far I'm very disappointed with the quality of help I've received. It's showing me how weak the community is around C and C++ whereas the community around python and perl leaves you guys looking like... well... words that shouldn't be uttered in public foura.
And please don't tell me, "well if you love perl so much why don't you just go away"... That is so below what I hoped you'd prove to be -helpful, friendy.
char *
getstring (char strquestion[255])
Like I said -works great but means nothing to me.
>sprintf returns the number of characters printed, not a string of any sort, which is what your use of getstring suggests. You could return lineofinput, and that would satisfy the type system, but then you would have problems because lineofinput is a local variable and is destroyed when the function returns. A much better solution would be to pass a pointer to the buffer to getstring. Then you can return a pointer to the buffer with no problem:
#include <stdio.h>
char *getstring ( char buffer[], int size )
{
if ( fgets ( buffer, size, stdin ) == NULL )
return NULL;
return buffer;
}
int main ( void )
{
char buffer[BUFSIZ];
if ( getstring ( buffer, sizeof buffer ) != NULL )
printf ( "%s\n", buffer );
return 0;
}
Thanks this is good information, but still doesn't /explain/ anything, like what the "*" does and where you get "BUFSIZ".
>>Unfortunately that isn't providing me with any answers to the question I've asked.
>Perhaps not the question you asked
now. If we give you a link (Dave or I in particular), we think you need the information whether you asked for it or not.
OK.
>>Please help me out here by guiding me with a little easier terms to understand.
>You read book. Use reference. It help make code good.
I really can't believe you just said that. I'm already working out of a book. Dare I ask if you know of any other places I could receive better help with C than this?