#include <stdio.h>
#include <string.h>
#include <ctype.h>
int getemail (char * email);
int getfirstname (char* firstname);
int getlastname(char * lastname);
int getphonenumber (char * phone);
void main ()
{
char email[30];
char firstname[80];
char lastname[80];
char phone[15];
int namevalid;
do {
namevalid=getfirstname(firstname);
if (namevalid ==1){
printf("You entered: %s, A good name\n",firstname);
}
else {
printf("You entered an INVALID name\n");
}
}
while (namevalid ==0);
}
int getfirstname (char * chararry);
{ int entryvalid =1;
int entrylength;
printf("enter the first name: ");
gets(chararray);
printf("You entered: %s\n",chararray);
//strlen give the length of an array of characters
entrylength-strlen(chararray);
if (entrylength ==0) {
return 0;
}
for (i =0; i< entrylengthl i++) {
if (chararray[i]== ' ')
entryvalid=0;
}
if (!isalpha(chararray[i])) {
enrtyvalid=0;
}
}
return entryvalid;
MrBentley
0
Newbie Poster
Recommended Answers
Jump to Postmain should always return an int, void main is non-standard.
You don't need the ; after line 30
Line 37, that statement does nothing.
Most importantly, never use gets. It is too easy to overflow the array to which you are writing as you have zero control …
Jump to PostHelp with this please,Im trying to learn c++ and i cant figure this out
There is no C++ in what you have written there. That is C. I have asked a moderator to move it there. Also, don't be so quick to bump your thread as it takes time to …
All 5 Replies
MrBentley
0
Newbie Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
MrBentley
0
Newbie Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.