tags:

views:

47

answers:

2

I have declared a char variable ope in function main. i took the input through getchar function and stored in ope. Now i want to blank the variable so i will be able to store some other in ope. Can anybody show me how to do it?? I just want to continuously store the input in ope variable. If it's possible through some other way, kindly guide me. I will be very thankful.

+1  A: 

You can reuse the getchar() function same way you used it first time.

Here is sample code from the cplusplus.

#include <stdio.h>

int main ()
{
  char c;
  puts ("Enter text. Include a dot ('.') in a sentence to exit:");
  do {
    c=getchar();
    putchar (c);
  } while (c != '.');
  return 0;
}
Praveen S
getchar() returns integer
Nyan
A: 

You don't need to blank it, just do getchar() once again. Eventualy set it to or "0 char"

c = '\0'; or c = 0;
killer_PL