Skip to main content
gamedev.net
๐Ÿ”’ Locked

error when adding

Started by lincsimp 1 reply 250+ views
Original Post
lincsimp
lincsimp
hi Why does the code below return an error?
stufftoadd = "f"+startnumber+"="+fword;
 
The error message is : error C2110: ''+'' : cannot add two pointers all help appreciated
Oluseyi
Oluseyi
String literals are not a first-class type in C++. The type of "Oluseyi" is char [7], not std::string.

Use a std::stringstream.
SiCrane
SiCrane
I''ll assume from your error message that you''re using MSVC. The problem here is that string constants in C/C++ are represented as character arrays and referred to by a char * pointer. Addition on two pointers is not defined.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.