Is it possible to store * and # in an array? I thought I could do this through the data type char. On top of that I was wondering if I could check the array elements to see if the element equaled that character, but I don't think that's possible.

Basically I have the following trial if someone could help me. I am still writing the pseudo code for my real program but I am trying to make sure I understand this because otherwise my pseudo code is all wrong and I am getting nowhere.

My code is the following:

char play[3];         // here i am trying to declare the array
play[2] = "*";       // set the 3rd element equal to the *

if(play[2] == "*")   // if it equals * then display
cout << "That seat is taken." << endl;

Recommended Answers

All 4 Replies

i dont think you should assign a char inside double quotes. Try

play[2] = '*'
if (play[2] == '*')

i dont think you should assign a char inside double quotes. Try

play[2] = '*'
if (play[2] == '*')

thanks that worked ;-D

'a' == char
"a" == string

'a' == char
"a" == string

Oh I see. Thank you as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.