Demonstrates using the gets_s() return value. - C String

C examples for String:String Console Input

Description

Demonstrates using the gets_s() return value.

Demo Code

#include <stdio.h>

int main( void ){
    char input[257], *ptr;

    puts("Enter text a line at a time, then press Enter.\n");
    puts("Enter a blank line when done.\n");

    /* Loop as long as input is not a blank line. */

    while ( *(ptr = gets_s(input)) != NULL){
        printf("You entered %s\n", input);
    }/*  ww w .  j a v  a 2  s  . com*/
    
    puts("bye\n");

    return 0;
}

Result


Related Tutorials