Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 30, 2022 03:18
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/33db5dcddbbb20a6dbca5e628bf8268d to your computer and use it in GitHub Desktop.
Save parzibyte/33db5dcddbbb20a6dbca5e628bf8268d to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <locale.h>
#define MAXIMA_LONGITUD_CADENA 100
int main(void)
{
char cadena[MAXIMA_LONGITUD_CADENA] = "";
setlocale(LC_NUMERIC, "");
long double dinero = 1234567.89;
snprintf(cadena, MAXIMA_LONGITUD_CADENA, "$%'.2Lf", dinero);
printf("La cadena formateada es '%s'", cadena);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment