C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How can I get the card symbols like Hearts and Clubs? Posted by Faz on 31 May 2006 at 5:42 AM
I have made a card game in C++ and I stumbled across a set of symbols at run-time. I realised why, I had an array of 5 integers and the program was trying to retrieve the data from the 6th variable, which it shouldn't have done! I've fixed the problem now, but it was pointing to a set of symbols, which came from the location directly after the array, which could have been anything!

Anyway, these symbols that were appearing were conveniently exactly what I was after. I need the 4 symbols in a pack of cards, Clubs, Spades, Diamonds, and Hearts.

I was rather hoping it would be something simple like "\s" for spades perhaps, like new line is "\n".

Can someone please help me find these symbols?
Report
Re: How can I get the card symbols like Hearts and Clubs? Posted by stober on 31 May 2006 at 6:04 AM
This message was edited by stober at 2006-5-31 6:7:8

you might search these web pages

http://www.google.com/search?hl=en&lr=&q=playing+card+graphics&btnG=Search

or you might install a new font that has them as replacement for some characters in the normal ascii character set.



Report
Re: How can I get the card symbols like Hearts and Clubs? Posted by Lundin on 31 May 2006 at 6:46 AM
: I have made a card game in C++ and I stumbled across a set of symbols at run-time. I realised why, I had an array of 5 integers and the program was trying to retrieve the data from the 6th variable, which it shouldn't have done! I've fixed the problem now, but it was pointing to a set of symbols, which came from the location directly after the array, which could have been anything!
:
: Anyway, these symbols that were appearing were conveniently exactly what I was after. I need the 4 symbols in a pack of cards, Clubs, Spades, Diamonds, and Hearts.
:
: I was rather hoping it would be something simple like "\s" for spades perhaps, like new line is "\n".
:
: Can someone please help me find these symbols?
:


They usually place them on top of the ASCII table, 0 to 32, which is reserved for non-printable symbols. However, the symbols are not standard, so they may vary on different systems. Here is a simple program to check what symbols are stored there on your system:

#include <stdio.h>

int main()
{
  int i;
  for(i=0; i<32; i++)
    printf("%d: %c\n", i, i);
  getchar();
  return 0;
}


Expect a beep at 7 and a linefeed at 10 :)

The symbols you are looking for are most likely:

3 hearts
4 diamonds
5 clubs
6 spades

meaning you could print them in strings as

'\x03'
'\x04'
'\x05'
'\x06'

(note that these are hex values, not decimal)
Report
Re: How can I get the card symbols like Hearts and Clubs? Posted by Faz on 31 May 2006 at 6:55 AM
: : I have made a card game in C++ and I stumbled across a set of symbols at run-time. I realised why, I had an array of 5 integers and the program was trying to retrieve the data from the 6th variable, which it shouldn't have done! I've fixed the problem now, but it was pointing to a set of symbols, which came from the location directly after the array, which could have been anything!
: :
: : Anyway, these symbols that were appearing were conveniently exactly what I was after. I need the 4 symbols in a pack of cards, Clubs, Spades, Diamonds, and Hearts.
: :
: : I was rather hoping it would be something simple like "\s" for spades perhaps, like new line is "\n".
: :
: : Can someone please help me find these symbols?
: :
:
:
: They usually place them on top of the ASCII table, 0 to 32, which is reserved for non-printable symbols. However, the symbols are not standard, so they may vary on different systems. Here is a simple program to check what symbols are stored there on your system:
:
:
: #include <stdio.h>
: 
: int main()
: {
:   int i;
:   for(i=0; i<32; i++)
:     printf("%d: %c\n", i, i);
:   getchar();
:   return 0;
: }
: 

:
: Expect a beep at 7 and a linefeed at 10 :)
:
: The symbols you are looking for are most likely:
:
: 3 hearts
: 4 diamonds
: 5 clubs
: 6 spades
:
: meaning you could print them in strings as
:
: '\x03'
: '\x04'
: '\x05'
: '\x06'
:
: (note that these are hex values, not decimal)
:

Excellent, thanks.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.