#include <stdio.h>
int main() {
char userName[100]; // Assuming the user's name will not exceed 100 characters
printf("Enter your name: ");
scanf("%99[^\n]", userName); // Read user input, limiting to 99 characters to leave room for null terminator
printf("Hello, %s! Welcome to C programming.\n", userName);
printf("Press any key to exit...\n");
getchar(); // Waits for any key press
return 0;
}
This code snippet provides a basic interaction with the user, demonstrating how to handle input and output in a simple C console application.
Please log in to leave a comment!