int getchar();
The getchar()
function is equivalent to a call to getc(stdin). It reads the next character from stdin which is usually the keyboard.
It is defined in <cstdio> header file.
None.
getchar()
function returns the entered character.EOF
.
eof
indicator on stdin
.stdin
.
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int c,i=0;
char str[100];
cout << "Enter characters, Press Enter to stop\n";
do
{
c = getchar();
str[i] = c;
i++;
} while(c!='\n');
cout << str;
return 0;
}
When you run the program, a possible output will be:
Enter characters, Press Enter to stop rtq paSd12 6.2 haQ rtq paSd12 6.2 haQ