ok i found a way to first transform a std:: string to a c string (char)
and from char using atoi function to get integer.
here is te
Code:
// strings and c-strings
#include <iostream>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main ()
{
char * cstr, *p;
string str;
cout << "input a string ";
cin >> str;
string s4( str , 2, 4);
cstr = new char [s4.size()+1];
strcpy (cstr, s4.c_str());
int a;
cout << " cstr = " << cstr <<endl;
a = atoi (cstr);
int b;
b = 100;
cout << " a = " <<a <<endl;
cout << " b = " << b + a <<endl;
return 0;
}
is there a more simple way to do this? does this slow down a computer?