0

I tried to add comma between the numbers, I already checked other question and I did it, but it still fail for me I don't know why. Here's my simple code :

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <locale.h>

int ticketPrint();

int main(){
    ticketPrint( 125000 );
}

int ticketPrint( int ticketPrices ){
    setlocale(LC_NUMERIC, "");
    printf("\xb3                         Total                        \xb3 %'d  \xb3\n", ticketPrices);
    return 0;
}

I expected : 125,000

But the output is 'd, any idea? or please tell me where is my fault, Thankyou

Barmar
  • 669,327
  • 51
  • 454
  • 560
Nico A.L
  • 25
  • 1
  • 7
  • 2
    The `'` flag is not described by the C Standard, it is a [POSIX extra](https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html). Maybe your system is not (fully) POSIX compliant. – pmg Nov 16 '21 at 07:47
  • So it means I can't make numbers with a comma? – Nico A.L Nov 16 '21 at 08:05
  • You can write your own function, maybe `print_wih_commas(int value);` and then use as, eg `printf("\xb3 Total \xb3 "); print_with_commas(ticketPrices); printf(" \xb3\n");` – pmg Nov 16 '21 at 12:13
  • Okay Thankyou.. – Nico A.L Nov 16 '21 at 12:25

0 Answers0