Skip to content

Instantly share code, notes, and snippets.

@rakia
Created May 3, 2024 16:00
Show Gist options
  • Save rakia/4758545a52ff956fb0b0b98505b176e6 to your computer and use it in GitHub Desktop.
Save rakia/4758545a52ff956fb0b0b98505b176e6 to your computer and use it in GitHub Desktop.
A Non-Memory-Safe C program
#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