#include <iostream>
#include <string>
using namespace std;
int main(){
int numberofchars;
string TempString;
bool moveon;
//variables
while(moveon=false){
cout << "how many characters do you want to input?" << endl;
cin >> numberofchars;
char InputString[numberofchars];
cin >> TempString;
if(TempString.length()!=strlen(InputString)){
cout << "strings not equal" << endl;
moveon=false;
}
else moveon=true;
}
cin.getline(InputString,numberofchars, '/n');
cout << InputString;
}
The error is 'InputString' undeclared (first use this function) on line 23.
WHY?
im thinking there might be something wrong with my compiler... sometimes when i hit compile and run it only compiles and doesnt run it. I have to manually go to the .exe file and run it from there :S
im using dev-c++ at the moment... what does everyone else use?
Thank you for reading and any responses are greatly appreciated :)
P.P.S. As InputString is full of random stuff (as it's un-init) on line 15 -- when you check it's length -- your test is going to do weird things. Maybe even crash!