C Tutorial/stdio.h/getchar — различия между версиями

Материал из C\C++ эксперт
Перейти к: навигация, поиск
м (1 версия: Импорт контента...)
 
(нет различий)

Текущая версия на 13:32, 25 мая 2010

getchar

Item Value Header file stdio.h Declaration int getchar(void); Function read a character from stdin. Return returns EOF on error.

Read characters from stdin into the array s until the user presses ENTER


<source lang="cpp">#include <stdio.h>

 int main(void)
 {
   char s[256], *p;
   p = s;
   printf("input char:");
   while((*p++ = getchar())!= "\n");
   *p = "\0"; /* add null terminator */
   printf(s);
   return 0;
 }</source>