C examples for Data Type:char
Break keyword is used with the if command to exit the loop when you press the ~ (tilde) key:
#include <stdio.h> int main()// ww w . j av a 2 s . c o m { char ch; puts("Start typing"); puts("Press ~ then Enter to stop"); for(;;) { ch=getchar(); if(ch=='~') { break; } } printf("Thanks!\n"); return(0); }