0

Whay '<'signed /unsigned mismatch error??

stack <char>stack1; string my_string="hello"; for (int i =0; i< my_string.length(); i++) { stack1.push(my_string[i]); }

30th Oct 2017, 7:47 AM
gehad
gehad - avatar
4 Respuestas
+ 2
I compiled and ran this that worked perfectly: #include <iostream> #include <stack> using namespace std; int main() { stack <char>stack1; string my_string = "hello"; for (int i = 0; i < my_string.length(); i++) { stack1.push(my_string[i]); } return 0; }
30th Oct 2017, 8:29 AM
John Wells
John Wells - avatar
+ 1
Change the int to size_t?
30th Oct 2017, 10:21 AM
aklex
aklex - avatar
0
@John Wells may be my compiler it dosn't work
30th Oct 2017, 10:12 AM
gehad
gehad - avatar
0
Interface says size_type, which is usually size_t.
30th Oct 2017, 12:44 PM
John Wells
John Wells - avatar