Use getchar inside while loop : While « Language Basics « C / ANSI-C






Use getchar inside while loop

  
#include <stdio.h>
#include <conio.h>

int main(void)
{
  char ch;

  ch = getchar();

  while(ch!='e') 
     ch = getchar();
  printf("Found the e.");

  return 0;
}

           
       








Related examples in the same category

1.While to sum integers
2.a while loop nested in for loopa while loop nested in for loop
3.While loop to print char