Danny's Tech Musings



String Operations III

posted under , , , , 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";
}

0 comments

Make A Comment
top