Created
May 3, 2024 16:00
-
-
Save rakia/4758545a52ff956fb0b0b98505b176e6 to your computer and use it in GitHub Desktop.
A Non-Memory-Safe C program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
void greet(char *input) { | |
char buffer[10]; | |
strcpy(buffer, input); // Copy input to buffer | |
printf("Hello, %s!\n", buffer); | |
} | |
int main() { | |
char name[20]; | |
printf("Enter your name: "); | |
gets(name); // Reads user input | |
greet(name); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment