No match for operator<<

On line 28 I'm receiving the error "no match for operator<<" followed by "note: candidates are". Could someone explain what the issue is?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <fstream>
#include <iomanip>




int main()
{
    std::string farmName, itemName;
    int countOfItem;
    float itemPrice;

    std::ifstream inFile;

    inFile.open("ASSGN6A.txt");

    std::cout << std::setfill('=') << std::setw(65) << "=" << std::endl;
    std::cout << "=" << std::setfill(' ') << std::setw(18) << "FARMER'S MARKET INVENTORY" << std::setfill(' ') << std::setw(18) << "=" << std::endl;
    std::cout << std::setfill('=') << std::setw(65) << "=" << std::endl;

    while(!(getline(inFile, farmName, ',')).eof())
    {
        inFile >> countOfItem;
        inFile >> itemName;
        inFile >> itemPrice;

        std::cout << farmName << std::setfill(10) << std::setfill(' ') << countOfItem << " " << itemName << " @ " << itemPrice << " each totalling " << itemPrice * countOfItem << std::endl;
    }

    inFile.close()



    return 0;
}
std::setfill(10) looks suspicious. ASCII character 10 is a line-feed. Did you intend setw() ?
Yes, that's what I meant to put. Thanks.
Maybe you want to have
#include <string>
in the header?

I should put
using namespace std;
after your include statements. Then remove all the std:: which are just making your lines unnecessarily long.
Last edited on
Topic archived. No new replies allowed.