C Tutorial/stdio.h/getchar


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

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


#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;
  }