[ create a new paste ] login | about

Link: http://codepad.org/9hdpx1Kn    [ raw code | output | fork ]

C++, pasted on Aug 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <string>
#include <iostream>
using namespace std;

int main()
{
	string str = "12.56 14";
	int    iParam = 0;
	double dParam = 0;
	//2 - означает число считанных параметров
	if(sscanf(str.c_str(),"%lf %d",&dParam,&iParam) != 2)
		cout<<"Error parsing params from string\n";
	else
		cout<<"int    : "<<iParam<<endl
			<<"double : "<<dParam<<endl;
	return 0;
}


Output:
1
2
int    : 14
double : 12.56


Create a new paste based on this one


Comments: