#include<iostream>
#include<conio.h>
#include<sstream>
#include<string>
using namespace std;
int main()
{
string s1;
int num;
long value;
string str="he is a good programmer 458";
int pos=str.find(" ");
while(pos!=string::npos)
{
str.replace(pos,1,",");
pos=str.find(" ",pos+1);
str.replace(23,1,":");
str.replace(24,1," ");
}
istringstream inputString(str);
inputString >> s1 >> num;
cout <<"String in the Memory..." <<endl<< endl<< s1 << endl<< endl<< "Integer in String..." << endl<< endl<<num<< endl << endl;
inputString >> value;
if( inputString.good())
{
cout <<"Value is ...: " <<value<< endl;
}
else
{
cout << "String is empty ....:" << endl;
}
getch();
return 0;
}
#include<conio.h>
#include<sstream>
#include<string>
using namespace std;
int main()
{
string s1;
int num;
long value;
string str="he is a good programmer 458";
int pos=str.find(" ");
while(pos!=string::npos)
{
str.replace(pos,1,",");
pos=str.find(" ",pos+1);
str.replace(23,1,":");
str.replace(24,1," ");
}
istringstream inputString(str);
inputString >> s1 >> num;
cout <<"String in the Memory..." <<endl<< endl<< s1 << endl<< endl<< "Integer in String..." << endl<< endl<<num<< endl << endl;
inputString >> value;
if( inputString.good())
{
cout <<"Value is ...: " <<value<< endl;
}
else
{
cout << "String is empty ....:" << endl;
}
getch();
return 0;
}