|
From: philip M. <ph...@co...> - 2003-04-25 16:42:27
|
You could have written:
printf("prompt > ");
scanf("%4s", buffer);
while (fgetc(stdin) != '\n');
> I try the following code:
>
> <snip>
> #include <stdio.h>
>
> int main(int argc, char** argv)
> {
> char buffer[5];
> while(1)
> {
> printf("prompt > ");
> scanf("%4[^\n]",buffer);
>
> printf("you typed: %s\n", buffer);
> printf("you typed: %d %d %d %d %d\n", buffer[0], buffer[1],
buffer[2], buffer[3], buffer[4]);
> }
>
> return 0;
> }
> </snap>
--------------------------------------------------------------------------
Philip Mortimer
www: http://mysite.freeserve.com/coniferway/index.html.
Available for short and long term contracts
---------------------------------------------------------------------------
|