1. #include <stdio.h>
  2. int main() {
  3. char userName[100]; // Assuming the user's name will not exceed 100 characters
  4. printf("Enter your name: ");
  5. scanf("%99[^\n]", userName); // Read user input, limiting to 99 characters to leave room for null terminator
  6. printf("Hello, %s! Welcome to C programming.\n", userName);
  7. printf("Press any key to exit...\n");
  8. getchar(); // Waits for any key press
  9. return 0;
  10. }
 
 

89

Pasted Text #34518

作者 Rosa Dunn

This code snippet provides a basic interaction with the user, demonstrating how to handle input and output in a simple C console application.

PasteBin

行數
13
字數
59
大小
443 位元組
建立時間
類型
text/x-chdr
All Rights Reserved ((C))
登入以留下評註!