#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;

Recommended Answers

All 5 Replies

Help with this please,Im trying to learn c++ and i cant figure this out

main 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 over how many characters the user enters. Use fgets instead.

Help 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 get a response.

I jus saw people looking didnt think they had a clue what i wanted hrlp with.

NVM I missed that you were replying to my second post

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.