Created
July 29, 2019 22:26
-
-
Save parzibyte/2f53e25725ad43a7fa65a41cf298b324 to your computer and use it in GitHub Desktop.
Convertir entero a cadena en C https://parzibyte.me/blog/2018/11/28/numero-cadena-c/
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
/* | |
Convertir entero a cadena en C | |
@author parzibyte | |
*/ | |
#include <stdio.h> // printf y sprintf | |
// Prototipo | |
void enteroACadena(unsigned long long numero, char *bufer); | |
int main(){ | |
unsigned long long numero = 18446744073709551615U; | |
char cadena[21]; // 21, porque puede medir hasta 20 y necesitamos un adicional para le carácter de terminación | |
enteroACadena(numero, cadena); | |
printf("El entero %llu se convierte a '%s' como cadena", numero, cadena); | |
} | |
void enteroACadena(unsigned long long numero, char *bufer){ | |
// Recuerda: llu es para un long long unsigned | |
sprintf(bufer, "%llu", numero); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment