Just when i thought this class could not get any harder i get this assignment. The last few lectures i have watched in my class on pointers have gotten me totally confused. Now i have this assignment due in 6 days that i seriously do not even know how to start. Any help would be very much appreciated. I have a few more assignments to do before this semester is over and i am trying to do well on them. But getting these assignments makes it very difficult...i have attached the directions for our assignment and what the output is supposed to look like....here is my starting setup...

//Assignment 8: Pointers, Functions, and Input Validation
//By: Curtis Davenport

#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{



	return 0;

}

Everytime i read the directions i have a question mark over my head...

>i have attached the directions for our assignment and what the output is supposed to look like
No, you haven't. But that's okay because I'd tell you that very few of us are willing to open attachments and that you'd have better luck if you just copy/pasted the details in your post.

O ok sorry well here is what it is supposed to do and look like....

-Write a program that asks the user to enter his/her first and last name in lowercase letters.

-The program must output the full name and the number of characters to the console after validating the inputs.

-Limit the size of both strings (first name and last name) to 100 characters.

-The input of each string must be done through a function. If the string is entered incorrectly the program must send a message and request it again.

-The function must return a Boolean parameter indicating the validity of the input (true if only lowercase characters and false otherwise).

-The string and its length must be the input parameters of the function and should be allowed to be changed from inside function (pointers).

-The function header must be as follows: bool GetString(char buf[], int *length)

Note: The character array (string) is stated in the function header with no explicit size (buf[]). This implies that the function is receiving the address of the first element of the array. This function can be called as: validString = GetString(string,&length);

Code output...

I'd post the output too. You're going to get fewer takers if they have to open up a file. It's not too long. You're given at least one function header, as well as a call to it. At the least, stick that function header at the top, write a function that does nothing but return true or false, then call it from main. When that's compiling and running with no errors, put some code, like a cout statement, within the function to make sure that your function is accurately being passed and can receive the parameters you intend it to. Have it display buf and *length and make sure those match what you passed from main. Then and ONLY THEN worry about the guts of the program.

Here is a commented code that does the same as the image. :)

//Assignment 8: Pointers, Functions, and Input Validation
//By: Curtis Davenport

#include <iostream>
#include <cstdlib>

using namespace std;

bool isValid(char *name) {

	if (strlen(name) > 100)	return false;

	for (int i = 0; name[i]; i++) {
		if (name[i] < 'a')	return false;
	}

	return true;

}

int main()
{

	char firstname[1000]; // Buffer for first name
	char lastname[1000];  // Buffer for last name

	bool validName = false;

	do {

		cout << "Enter your first name is lowercase letters: ";
		cin >> firstname; // Allow user to enter first name
		validName = isValid(firstname);
		if (validName == false) cout << "Invalid entry. Try again...\n";

	} while (validName == false);

	cout << "\n"; // new line

	do {

		cout << "Enter your last name is lowercase letters: ";
		cin >> lastname;  // Allow user to enter last name
		validName = isValid(lastname);
		if (validName == false) cout << "Invalid entry. Try again...\n";

	} while (validName == false);

	cout << "\n";

	cout << "Your full name is " << firstname << " " << lastname << "\n\n";
	cout << "Your full has " << strlen(firstname) + strlen(lastname) << " characters\n";

	system("pause");

	return 0;

}
commented: Very knowledgable +1

You know this stuff makes sense after it is in front of you... I have a rough time trying to get a prompt and trying to create it. Im just not made for this stuff... But thanks so much for your help, this class has been incredibly tough for me. Im trying to learn but it is difficult...

if it's something you feel you might want to do in life, don't give up. the rewards of programming are great.

also, hello everyone. i've always read all the posts of this forum, but for some reason never bothered signing up. i decided to, and here i am.

i'm looking forward to being a part of this community.

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.