On Sat, Jun 7, 2008 at 5:46 PM, Bill Cunningham <[EMAIL PROTECTED]> wrote:

>    OK. I see what you mean now. Let me try this. instead.
>
>> int main(void) {
>>     int buf[10];
>>     char *input;  /* for parameter 1 */
>>     fgets( input, sizeof(buf), stdin );
>>     printf( "%s\n", input );
>> }

You're getting closer. But you need to allocate memory for char
*input. And as I said before, buf[] is unnecessary. Create a #define
like BUFSZ 10 and use that to allocate the memory using malloc, and
remember your buffer needs to be BUFSZ + 1 to hold the terminating
'\0'.

>> This should, and this is untested, print a string from input.

You should try compiling and running your code before posting. It's
the best way to learn C, rather than guesswork.

-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
 If I were to divulge it, it would overturn the world."
 -- Jelaleddin Rumi

Reply via email to