I could use cin but I would like to learn other ways of handling this. I have looked up the getline function but Im having problems implementing it for this program.
Im hoping you people could give me some advice.
This works:
Code:
void main ()
{
char a[64];
cout << "enter number\n";
while(notvalid(a))
{
cout << "a = ";
cin.getline(a,64);
}
getch();
}
This does not:
Code:
void main ()
{
char a[64];
printf("enter number\n");
while(notvalid(a))
{
printf("a = ");
scanf("%s", &a);
}
getch();
}
When I say "it works" or "it doesnt work", Im refering to entering a number and if the number is not valid then you must reinput the number. but when something like "-235 326.2" (notice the space) is entered scanf allows it?????
Thanks,
Ryan