5 Replies - 17453 Views - Last Post: 27 October 2006 - 06:42 AM Rate Topic: -----

#1 //no_comment  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 15-September 06

ASCII Characters

Posted 25 October 2006 - 07:42 PM

Help! I am writing a program that will simulate a card game, and was wondering if anyone knew the code to print out characters such as a heart, spade, etc. I copied them into the code as characters, but they print to the screen as question marks.
Is This A Good Question/Topic? 0
  • +

Replies To: ASCII Characters

#2 gregoryH  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 60
  • View blog
  • Posts: 656
  • Joined: 04-October 06

Re: ASCII Characters

Posted 26 October 2006 - 01:04 AM

View Post//no_comment, on 25 Oct, 2006 - 07:42 PM, said:

Help! I am writing a program that will simulate a card game, and was wondering if anyone knew the code to print out characters such as a heart, spade, etc. I copied them into the code as characters, but they print to the screen as question marks.

the ability to print special characters is related to something called a "code page".

Try looking up MSDN for information
Was This Post Helpful? 0
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: ASCII Characters

Posted 26 October 2006 - 08:19 AM

It is kinda of operating system dependant but you could use the following escape characters on Windows to get those symbols.

\3 and \4 and \5 and \6.
Was This Post Helpful? 0
  • +
  • -

#4 //no_comment  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 15-September 06

Re: ASCII Characters

Posted 26 October 2006 - 07:57 PM

Thanks for all the help so far. I initialized an array of strings with 52 elements each containing the possible card number and suit. When I build it there are no errors, but when i attempt to debug, I receive an error message to the effect of null.reference.exception. Does anyone know what this means and how I can fix it. Here is my array:

string card1[DECK]= {"1\3","2\3","3\3","4\3","5\3","6\3","7\3","8\3","9\3","J\3","Q\3","K\3","A\3",
						
"1\4" ,"2\4","3\4","4\4","5\4","6\4","7\4","8\4","9\4","J\4","Q\4","K\4","A\4",
						
"1\5" ,"2\5","3\5","4\5","5\5","6\5","7\5","8\5","9\5","J\5","Q\5","K\5","A\5",
					   
 "1\6" ,"2\6","3\6","4\6","5\6","6\6","7\6","8\6","9\6","J\3","Q\6","K\6","A\6"};



I take that back, i just commented out some lines of code and it compiled correctly.

string hand1[HAND]={0};
	string hand2[HAND]={0};
				string discard[DECK]={0};



These are the arrays that will hold the cars for each player and the discard pile. Can anyone spot what is causing it to give me the null reference error? *When i stop initializing the arrays to zero, the problem dissapears also.

This post has been edited by //no_comment: 26 October 2006 - 07:58 PM

Was This Post Helpful? 0
  • +
  • -

#5 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: ASCII Characters

Posted 26 October 2006 - 09:57 PM

These are strings and as such you need to initialize them this way:
string hand1[HAND]={""};
	string hand2[HAND]={""};
				string discard[DECK]={""};


Was This Post Helpful? 0
  • +
  • -

#6 //no_comment  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 15-September 06

Re: ASCII Characters

Posted 27 October 2006 - 06:42 AM

I can't believe i forgot the quotes! Thanks so much for pointing that out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1