Reputation: 279
Sorry, this is a really simple question but I can't find the answer...I have implemented a char stack with a push function that takes in a char to push into the stack. However, I don't know how to actually declare a char to push into the stack.
I've tried doing this, but I get an error saying that I'm trying to convert from a const char* to a char:
int main(){
char_stack stack;
char c = "x";
s1.push(c);
}
I've also tried doing this, but I think that's making c into a char*, and since my push function takes in only chars, I get another error.
int main(){
char_stack s1;
char c[] = "p";
s1.push(c);
}
Thanks!!
Upvotes: 0
Views: 143
Reputation: 56
Try with char c = 'x';
. What you are trying is defining a string (char array) and assigning to char variable.
Upvotes: 1