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. }
 
 

101

Pasted Text #34518

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

PasteBin

Zeilen
13
Wörter
59
Größe
443 Bytes
Erstellt
Typ
text/x-chdr
All Rights Reserved ((C))
Bitte melde Dich an, um einen Kommentar zu verfassen!