V
vsuresh.cs
Hi,
My c++ program looks likes this
void api1() {
cin << info;
ostringstream ostr;
ostr << info;
api2(ostr.str().c_str()); // Getting string from ostreamstream and
getting char* from string
}
void api2(const char* ch) {
insert map(ch);
}
Sample input to api2 "a" after that when i checked the content of map
at the end. I am seeing some junk values.
Can some one explain what is going wrong in my program? Do i should
not do c_str() on ostringstream?.
Thanks,
Suresh
My c++ program looks likes this
void api1() {
cin << info;
ostringstream ostr;
ostr << info;
api2(ostr.str().c_str()); // Getting string from ostreamstream and
getting char* from string
}
void api2(const char* ch) {
insert map(ch);
}
Sample input to api2 "a" after that when i checked the content of map
at the end. I am seeing some junk values.
Can some one explain what is going wrong in my program? Do i should
not do c_str() on ostringstream?.
Thanks,
Suresh