The std::string::append()
method expects its argument to be a NULL terminated string (char*
).
There are several approaches for producing a string
containg an int
:
std::ostringstream
#include <sstream> std::ostringstream s; s << "select logged from login where id = " << ClientID; std::string query(s.str());
std::to_string
(C++11)std::string query("select logged from login where id = " + std::to_string(ClientID));
boost::lexical_cast
#include <boost/lexical_cast.hpp> std::string query("select logged from login where id = " + boost::lexical_cast<std::string>(ClientID));
Related Posts:
- Why is “using namespace std;” considered bad practice?
- How to find out if an item is present in a std::vector?
- How do I reverse a C++ vector?
- Replace part of a string with another string
- Issue with std::stol – ‘std::invalid_argument’ what(): stol
- Is there a tab equivalent of std::endl within the standard library?
- Why am I getting string does not name a type Error?
- printf with std::string?
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- error C2065: ‘cout’ : undeclared identifier
- I’m getting the error “stoi is not a member of std” in myprogramminglab [duplicate]
- How many spaces for tab character(\t)?
- How do I build a graphical user interface in C++? [closed]
- What are the differences between a pointer variable and a reference variable in C++?
- Unresolved external symbol in object files
- How do sizeof(arr) / sizeof(arr[0]) work?
- rand() between 0 and 1
- how to implement Interfaces in C++?
- What exactly is nullptr?
- How to make a SIMPLE C++ Makefile
- finding dll for “The specified module could not be found”
- no matching function for call to ‘ ‘
- Read file line by line using ifstream in C++
- Convert an int to ASCII character
- When should I write the keyword ‘inline’ for a function/method?
- When does a process get SIGABRT (signal 6)?
- What is uintptr_t data type
- Why do we use volatile keyword? [duplicate]
- C++ round a double up to 2 decimal places
- Windows 7 exception code: 0xc0000409
- Convert float to std::string in C++
- “items list” or “item list”
- When and why do I need to use cin.ignore() in C++?
- What does int & mean
- Evaluate a string with a switch in C++ [duplicate]
- “&” meaning after variable type
- How can I create objects while adding them into a vector?
- What is the printf format specifier for bool?
- libpng warning: iCCP: known incorrect sRGB profile
- In CLion, header only library: file “does not belong to any project target, code insight features might not work properly”
- Is a function definition not allowed here before a ‘{‘ token?
- warning: control may reach end of non-void function
- Error at constructor : Expected an identifier?
- identifier “string” undefined?
- What does LPCWSTR stand for and how should it be handled with?
- A warning – comparison between signed and unsigned integer expressions
- How can I convert const char* to string and then back to char*?
- How do I call the class’s destructor?
- Can’t resolve Error: indirection requires pointer operand (‘int’ invalid)
- Defining a struct in flex error C++
- C++ Postfix calculator using stacks
- LNK1168: cannot open debug\file.exe for writing
- what does “error : a nonstatic member reference must be relative to a specific object” mean?
- Can I output a one channel image acquired from camera into a winAppi window?
- error: request for member ‘..’ in ‘..’ which is of non-class type
- Socket API or library for C++?
- Initialize empty vector in structure – c++
- Why is my HelloWorld function not declared in this scope?
- What is the difference between include_directories and target_include_directories in CMake?
- Undefined reference to constructor
- Copy a file in a sane, safe and efficient way
- c++ convert string to hex
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- expected constructor, destructor, or type conversion before ‘(’ token
- Passing as const and by reference – Worth it?
- expression did not evaluate to a constant- c++
- Generate SHA256 in c++
- A good and basic implementation of BigInt class in C++
- What is the C equivalent to the C++ cin statement?
- c++ Read from .csv file
- Check if C++ Array is Null
- Does C++11 have C#-style properties?
- How to print a string in C++
- How to check if input is numeric in C++
- C++ Big Integer
- How do I create a random alpha-numeric string in C++?
- Learning to work with audio in C++
- Creating an instance of class
- C++ Void Function with File Stream Error
- sorting in std::map where key is a std::string
- System not declared in scope?
- no debugging symbols found when using gdb
- C++ Array of pointers: delete or delete []?
- ERROR: Control may reach end of non-void function /
- Function stoi not declared
- What’s the difference between while(cin) and while(cin >> num)
- Too many arguments to function
- not declared in this scope’ when using strlen()
- Converting a Cubemap into Equirectangular Panorama
- Negative RGB Values
- DEV C ++ Error: expected declaration before ‘}’ token
- “cannot be used as a function error”
- error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
- Displaying contents of a vector container in C++
- Converting string to unsigned int returns the wrong result
- Visual c++ can’t open include file ‘iostream’
- c++ vector bubble sort
- compare and swap vs test and set
- Weighted random numbers
- compare and swap vs test and set