-
simple string problem
Ok I am new to C++ and I have this problem:
Code:
details = dateStr + "," + staffid + "," + totalitems + "," + totalprice + "," + payment_method + "," + amount_paid + "\n";
error C2110: cannot add two pointers
Any help on this? The data strucutres are:
string details;
char dateStr[9];
int staffid;
int totalitems = 0;
double totalprice = 0;
int payment_method;
double amount_paid = 0;
-
Post a bit more of the code. When you say data structrues, I think of this:
Code:
struct Fruit
{
string lemon;
int lemonAmount;
};
You have a list of varible declarations
-
try this
Code:
#include <string>
#include <sstream>
int main()
{
std::string details;
std::stringstream stuff;
char dateStr[9] = "Hello";
int staffid = 0;
int totalitems = 1;
double totalprice = 0.5;
int payment_method;
double amount_paid = 0;
stuff << dateStr << "," << staffid << "," << totalitems << "," << totalprice << ",";
details = stuff.str();
}
-
Thanks a lot, that really helps :)