Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone, as an exam test I have to program a solitaire. I am having difficulty showing the suits of the cards. If I convert the decimal number into an ASCII symbol, the output returns a question mark "?"; the same if I copy the character of a seed is converted directly to a question mark "?" from the compiler. Is there a way to show the sign instead of the question mark? As a compiler I use Dev-C ++ and the language is C.
Can someone please help me out?

What I have tried:

C#
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>

#define PICCHE L"\u2660"
#define FIORI L"\u2663"
#define CUORI L"\u2665"
#define QUADRI L"\u2666"

int main()
{
	_setmode(_fileno(stdout), _O_U16TEXT);

	printf  ("A\n" QUADRI);
	printf  ("K\n" FIORI);
	printf  ("Q\n" CUORI);
	printf  ("J\n" PICCHE);

	_setmode(_fileno(stdout), _O_TEXT);

	return 0;
}

I tried as well but it returns the question mark :

C#
#include <stdio.h>
int main ()
{
	printf ("%c",5);
	return 0;
}
Posted
Updated 10-May-20 21:33pm
v5

Take a look at MSDN documentation: _setmode | Microsoft Docs[^]

C
// crt_setmodeunicode.c
// This program uses _setmode to change
// stdout to Unicode. Cyrillic and Ideographic
// characters will appear on the console 
//(if your console font supports those character sets). -- this part is very important!

#include <fcntl.h>
#include <io.h>
#include <stdio.h>

int main(void) {
    _setmode(_fileno(stdout), _O_U16TEXT);
    wprintf(L"\x043a\x043e\x0448\x043a\x0430 \x65e5\x672c\x56fd\n"); //wprintf is used instaed of printf
    return 0;
}
 
Share this answer
 
Comments
Member 14827806 11-May-20 9:24am    
Problem solved, thank you very much
Maciej Los 11-May-20 14:48pm    
You're very welcome.
#include <iostream>

using namespace std;

int main( ){
char diamond[2] = {'\4'}, club[2] = {'\5'}, heart[2] = {'\3'}, spade[2] = {'\6'};
cout << diamond << club << heart << spade;
return 0;
}
 
Share this answer
 
Comments
OriginalGriff 28-Jul-21 0:54am    
If you post a solution - particularly to a "solved" question - you had better make sure it's good, or at the very least works.

Which this doesn't.

And "fresh" as well - new answers to new questions!

Which this isn't.

Answering year old solved questions with poor code fragments makes you look like a troll, an idiot, or a rep point farmer - and two of those will get you kicked off the site in very short order! The one in the middle will just get you ridiculed, and maybe kicked off the site.

Pick new questions, test your code before you post a solution, and you'll be fine.
Post garbage to old questions, and you'll pick up a ban very quickly! I'll let it go this time, but there are much more trigger happy members than I, so do it again and the process will almost certainly start ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900