On Tue, 20 Jul 1999, David FRYDMAN wrote:



If your problem here is as follows:

Enter a string, and then a char, then print the string, and then the char,
where the delimiter between the string and the char may be '\n' or space
(for example), i.e.:

/run
ABC
D
scanf accept ABC
getchar accept D

/run
ABC D
scanf accept ABC
getchar accept D

(is this the way it's supposed to work ?)

If so, the just a tiny change to scanf will make it work:

-scanf("%s",str);  (your version)
+scanf("%s\n",str); (my version)


If this is not what it was supposed to do, then ignore.

--Ariel
> 
> > Hi,
> > I have a small C program wich i compile with GNU C Compiler 2.8.1 and
> > 2.7.
> > and i got the same result in both times.
> >
> > #include <stdlib.h>
> > #include <stdio.h>
> > #include <string.h>
> > main()
> > {
> >char str[10];
> >int num;
> >scanf("%s",str);
> >printf("scanf accept %s\n",str);
> >num=getchar();
> >printf("getchar accept %c\n",num);
> > }
> >
> > For some reason "getchat()" accept Null string and do'ntprompt for
> > the user.
> > I runkernel 2.2.3 on pentium 120 with 32MG
> > I am sure it is somting simple but i just can'nt see it!!
> > Does anybody have any idea about it?
> > Thank you
> 

--
Ariel Biener
e-mail: [EMAIL PROTECTED]           Work phone: 03-640608
fingerprint = 07 D1 E5 3E EF 6D E5 82 0B E9 21 D4 3C 7D 8B BC


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to