logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/cs256su21code/may26/helloName2.c

/*

Here, this program is similar to helloName.c, execpt we are using
the function "gets" to handle input.

You should never use gets, because gets does not check for buffer overflow, which means that
the end user can enter more characters than we alloted, and can end up crashing your program 


*/


#include <stdio.h>

int main() { 

    char name[30]; //creating character array for 30 characters
    			   //last character of string you input in is '\0' signifies the end of the string
    			    
    printf("Who is this? "); //prompting for a name
    gets(name); //calling gets, all gets wants is the name of your character array
    printf("Hello, %s!\n", name); //prints out the string
    return 0;


}