Im talking about the string validation in void enter() , what im trying to do is create a system , where if someone accidentally puts a number in Enter name field , they need to write it again
im just not being able to solve this string validation at all.
I tried something like after cout<<"Enter name";
for(int i=0;i<strlen(name);i++)
{
gets(name);
if(isalpha(name[i]))
cout<<"There is a number in the input , try again";
}
include<fstream.h>
include<stdio.h>
include<conio.h>
include<string.h>
include<stdlib.h>
class Directory
{
char name[20];
char num[30];
char address[50];
public:
void enter()
{
cout<<"Enter name: "<<endl;
gets(name);
cout<<"Enter number: "<<endl;
gets(num);
cout<<"Enter address: "<<endl;
gets(address);
}
it did work , but if I enter a name "mar3", now i have to enter Mark four times for it to take the record.