Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i convert c++ str to int? [duplicate]

Tags:

c++

Possible Duplicate:
c++ converting string to int

I have the user input 9 numbers in sequence. I need to convert the string numbers to an int

string num;
int num_int, product[10];

cout << "enter numbers";
cin >> num;

for(int i =0; i<10; i++){
   product[i] = num[i] * 5; //I need the int value of num*5
}
like image 209
user1082764 Avatar asked Dec 18 '25 03:12

user1082764


1 Answers

Why don't you just read immediately to an integer?

int num;
cin >> num;