On this page
  1. gets
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

gets

Prev: sprintf | Up: stdio.h | Next: scanf
Rel: fgets(), stdio.h, stdio.h & File I/O Guide
Ref: cppreference — gets
Tags: #public #prog #c #stdlib #stdio #tier/legacy


Include

#include <stdio.h>

Signature & Overview

char *gets(char *str);  /* REMOVED in C11 */

Reads a line from stdin with zero bounds checking; removed from ISO C11.

Legacy / Avoid: Prefer fgets() in all new code.

Notes & Pitfalls

Example

#include <stdio.h>

int main(void) {
    char buf[64];
    // Safe replacement for removed gets():
    if (fgets(buf, sizeof(buf), stdin)) { /* process buf */ }
}

Linked from

Related notes