2. Convert an integer to a string in C++
#include <sstream>
string convertInt(int
number)
{
stringstream ss;//create a stringstream
ss <<
number;//add number to the stream
return
ss.str();//return a string with the contents of the stream
}
3. Assertion in C++
Code:
#include <cassert>
int main()
{
int* array =
NULL;
assert(array !=
NULL); // this should fail
return 0;
}
output is:
Code:
Assertion failed: array != NULL, file test.cpp, line 7
abnormal program termination