#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main()
{
char s[5];
string g;
int p=345;
sprintf(s,"%d",345);
g=s;
g+=".mp3";
cout<<g<<endl;
getchar();
return 0;
}
I have a very small doubt about strings. this is code snippet i have shown. when i have called sprintf(), then it has changed 345 to string with NULL character at this end. right ? so when i equalize g with s, then it is also = to 345. but qstn is that why string is rejecting NULL at the end ? and what can i do if i want to have a NULL in the g when i am writing "g=s". please help me if u can. thanks. (i am just learning all these things, not a experieced C++ programmer).