Thread: simple string problem

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    4

    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;

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    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
    Double Helix STL

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    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();
    }
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    4
    Thanks a lot, that really helps

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  3. C/C++ String Problem.
    By Jaken Veina in forum C++ Programming
    Replies: 7
    Last Post: 07-09-2005, 10:11 PM
  4. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 12:03 AM
  5. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM