how can change string to integer?

do not store it in word again because you declared word at first as string
so instead create another variable of type( int/float/double) and do the “stoi(word)”
(add this to your code and remove the word=stoi(word)” )

here is full code :

#include <iostream>
#include <string>
using namespace std;
int main()
  int x;
  string word;
  //now you can use x in any mathematical operation you want
  //try couting the x or (add, multiply,...etc to it)

Browse More Popular Posts

Leave a Comment