Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 31, 2020 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/7083a4220d3ee30af963beaf46ffbbdc to your computer and use it in GitHub Desktop.
Save parzibyte/7083a4220d3ee30af963beaf46ffbbdc to your computer and use it in GitHub Desktop.
/*
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