-
-
Save parzibyte/7083a4220d3ee30af963beaf46ffbbdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://parzibyte.me/blog | |
*/ | |
#include <stdio.h> | |
#include <string.h> // Para strlen | |
#define MAXIMA_LONGITUD_CADENA 50 | |
int main(int argc, char const *argv[]) | |
{ | |
char nombre[MAXIMA_LONGITUD_CADENA]; | |
printf("Ingresa tu nombre completo: "); | |
fgets(nombre, MAXIMA_LONGITUD_CADENA, stdin); | |
// Remover salto de línea | |
if ((strlen(nombre) > 0) && (nombre[strlen(nombre) - 1] == '\n')) | |
{ | |
nombre[strlen(nombre) - 1] = '\0'; | |
} | |
printf("Hola, '%s'", nombre); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment