String Operations III
posted under
C program
,
C++ program
,
character arrays
,
string operations
,
strings
by Anonymous
#include <cctype>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstdlib>
int readInt( const std::string &s )
{
int value;
std::sscanf( s.c_str(), "%d", &value );
return value;
}
double readDouble( const std::string &s )
{
double value;
std::sscanf( s.c_str(), "%lf", &value );
return value;
}
char readChar( const std::string &s )
{
char value;
std::sscanf( s.c_str(), "%c", &value );
return value;
}
bool readBool( const std::string &s )
{
bool value;
return s == "true";
}

Comment Form under post in blogger/blogspot