0
#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;
2
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by jonsca
0

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

0

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.

0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.