Red Dragon said:
Sorry. What is Google Groups? I am using Outlook Express and Visual C++
platform.
Sorry, my mistake.
groups.google.com has a broken interface that encourages users to post
followups with no attributions or quoted text. I don't know why I
didn't check your article's headers before assuming you were using
Google Groups.
In general, posting a followup that doesn't quote any of the parent
article is considered rude.
Thank you. Here is a program to illustrate my point.
/*Program to Demonstrate getchar() and scanf()*/
#include <stdio.h>
int main (void)
{
char a,b;
/*Section 1*/
printf("Enter a character > ");
scanf("%c",&a);
printf("a=%c\n",a);
printf("Enter another character > ");
getchar("%c",&b);
printf("b=%c\n",b);
Ok, I was starting to write an explanation of what this code does when
I noticed this call:
getchar("%c",&b);
getchar() takes no arguments and returns an int value representing
the value of the input character or EOF. You have the required
"#include <stdio.h>" at the top of the program, so the compiler
knows this. Any working C compiler should give you an error message
on that line, or at least a warning.
Either you're running the compiler in a mode that causes it not to
display the error message (don't do that), or you're getting a warning
and ignoring it (don't do that), or the code you posted isn't the same
as the code you compiled (once again, don't do that).
If you're going to post code, you need to copy-and-paste the *exact*
code that you fed to the compiler. If you try to re-type it, you'll
make mistakes (I know I would), and there's no way we can guess which
errors are in the original code and which you introduced by re-typing
it.
If that really was the code you compiled, including the getchar() call
with too many arguments, you need to compile without turning off
diagnostic messages, and you need to fix any errors flagged by the
compiler.
[...]
BTW, Do you have HTML problem with my program above?
Not that I can see, but I think my newsreader sometimes quietly
renders HTML as plain text.