Why can't I do this (if statement)

it feels like the answer is obvious, which it probably it, but I really can't figure this one out.

here's my code
1
2
3
4
5
6
7
8
9
10
11
12
         for(int count=0; count<50; count++)
         {
                 if(items[count] = "")
                 {
                                 system("pause");
                                 buy();
                 }
                 else
                 {
                 cout << items[count] << endl;
                 }
         }

I have an array with 50 slots, but i'm only using 6 of them and I will need more so I can add more entries later on. I want it to stop printing out each slot when it reaches one with nothing in it.

any tips? I just get this error message could not convert `((+(((unsigned int)count) * 4u)) + ((std::string*)(&items)))->std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const char*)""))' to `bool'
Last edited on
closed account (3hM2Nwbp)
1
2
3
4
5
6
7
8
9
10
11
12
         for(int count=0; count<50; count++)
         {
                 if(items[count] == "") // == is used for comparing, not =
                 {
                                 system("pause");
                                 buy();
                 }
                 else
                 {
                 cout << items[count] << endl;
                 }
         }
yeah i realised about 10 minutes after posting this :P rookie mistake.

thanks though :)
Topic archived. No new replies allowed.