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

87

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

Linhas
13
Palavras
59
Tamanho
443 bytes
Criado
Tipo
text/x-chdr
All Rights Reserved ((C))
Por favor faça seu login para deixar um comentário!