hi guys, i have just one simple doubt i hope you can clear for me, i have a restriction here, and it goes through the whole vector verifying if there is a null value
#include <iostream>
usingnamespace std;
int main() {
char number[20];
bool isNumber;
do{
isNumber = true;
cout<<"enter your number: ";
cin>>number;
for(int i = 0; number[i] != '\0'; i++){
if(!isdigit(number[i])){
isNumber = false;
cout<<"\nYour Number is Invalid\n";
break;
}
}
}while(!isNumber);
cout<<"\nThe Number you entered is: "<<numero;
cin.get();
return 0;
}
but if i enter for example '3 e', like that with the space, it stops, takes the 3 and adds the e to the next thing i enter. so usually then it crashes when the next variable i'm going to enter is an int.
i don't know if i explained myself perfectly jaja, i would appreciate if you help me.
and why would you need spaces ? numbers doesn't have spaces ?
~~~~~~~~~
Also i recommend to use std::string instead of fixed sized char array, but you have to use getline( cin, number ) instead and change number declaration to string number;