Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 17, 2019 01:45
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/305925c76fc2f148e37e77e6b2406702 to your computer and use it in GitHub Desktop.
Save parzibyte/305925c76fc2f148e37e77e6b2406702 to your computer and use it in GitHub Desktop.
int longitudDeseada = 8;
char *cadena = "01";
char *relleno = "00000000";
// Obtener la diferencia de longitud
int diferencia = longitudDeseada - (int) strlen(cadena);
printf("%*.*s%s ", diferencia, diferencia, relleno, cadena);
// Salida: 00000001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment