I have the following code:
//Comp454 program 2
#include <iostream>
#include <string>
#include <fstream> // file I/O support
#include <cstdlib> // support for exit()
const int SIZE = 60;
int main()
{
using namespace std;
string states;
int numStates = 0, i = 0, stateVar = 0;
string line;
char filename[SIZE];
ifstream inFSM, inString;
//Open FSM definition
cout << "Enter name of FSM definition: ";
cin.getline(filename, SIZE);
inFSM.open(filename); //Associate inFile with a file
if (!inFSM.is_open()) // failed to open file
{
cout << "Could not open the file " << filename << endl;
cout << "Program terminating.\n";
exit(EXIT_FAILURE);
}
//Process FSM definition line by line until EOF
getline(inFSM, states);
numStates = Int32.TryParse(states);
//Check for num of states
if(numStates > 10)
{
cout << "There can be no more than 10 states in the FSM definition, exiting now." << endl;
return 0;
}
while (!inFSM.eof()) // while input good and not at EOF
{
getline(inFSM, line);
cout << line << endl;
}
return 0;
}
I'm trying to convert a string to an integer using Int32.TryParse(), but when I compile I get the error that Int32 was not declared in this scope. Not sure why this is coming up, am I missing a namespace declaration?? Any help is appreciated, thank you
UPDATE: Thanks for all the responses, as in the comment I posted, I'm not trying to use C++/CLI, how to I convert a string, declared from the string class, to an integer?