[Solved] Error message saying “expected primary-expression before ‘for'”


The problem is that you’re trying to cout a for loop:

cout << "$200 - $299\t\t" << counter[1] << "\t\t" << for(i = 0; i < counter[1]; i++){ cout << "*"; };

…but it’s not possible to do that. Instead, break the output down – single strings can be output using cout << "something";, and anything inside of the for loop can be output separately, as shown in the example below:

#include <iostream>

int main()
{
    cout << "Hello: ";
    for(int i = 0; i < 10; ++i) { cout << "*"; };
}

You can run this example online here.

1

solved Error message saying “expected primary-expression before ‘for'”