//*************************************************************************************
//                      This program keeps track of speakers' bureau.
//          It displays a menu, where the user can add info,
//          view the info of another speaker that's already in there,
//          and etc.
//*************************************************************************************

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;

//**************************************************************************************
// this is the Speaker structure combines the info/data about a speaker
//**************************************************************************************
struct Speaker{
    const int SIZE = 50;  
    char name [SIZE] = "_";
    char telNumber[SIZE] = "_";
    char topic [SIZE]= "_";
    double fee = 0;

};

//**************************************************************************************
// this function displays the menu to the user
//**************************************************************************************
void displayMenu(){
    cout << "\n\tWelcome to Speaker's Bureau Menu\n\n";
    cout << "1. Add a speaker\n";
    cout << "2. View speaker's info\n";
    cout << "3. Display the number of speakers that are on the list\n";
    cout << "4. Quit the program\n\n";
}

//**************************************************************************************
// this function inputs, validates and returns the user's menu choices
//**************************************************************************************
int getChoice(){
    int choice;
    cin >> choice;
    while (choice < 1 || choice > 4){
        cout << "Please, enter the valid choice input, 1-4.";
        cin >> choice;
    };
    return choice;
}

//**************************************************************************************
// this function lets the user add info of a speaker
//**************************************************************************************
//void addSpeaker(){

//  return;
//}

//**************************************************************************************
// main function
//**************************************************************************************
int main(){

    int choice;
    do{
        displayMenu();
        choice = getChoice();

        if(choice == 1){

        };
    }while (choice != 0);


    return 0;
}

First of all, my program isn't complete yet, cause, I'm stuck. So, sorry if it looks messy or crappy.

Lemme, give you an idea of what my program should do:
It displays a menu of 4 choices - User chooses one - and each choice calls for a function - and so forth.

Here is my question:
1) As you see up top, inside the "struct Speaker", i've got 4 variables. They are all supposed to be in C-STRING. And C-STRING is like an array. The question is: after I declare the size of those variables, let's say I put 10 to the "NAME" variable...what if someone's name is longer/shorter than that? Is there a way of making it default or something?

2) The program overall is supposed to take input from the user, do some displaying and so forth. I have to store those data inputs into an ARRAY OF STRUCTUREs. How can I do that? I am having a hard time wrapping my head around it.

Please, someone HELP!!!

Thanks in advance!

Well if you need dynamic c-string arrays I would suggest using string from the STL. as far as an a array of structures thats pretty simole too. you can use a hard coded array or you can use one of the containers avalible in the STL. In this case a would use a vector.

struct Speaker
{
    string name;  // use string here for any size string
    string topic;
    string telNumber;
    double fee;
}

Then you can have a vector of Speakers that will hold each speaker that you have. With that vector you can add to it search through it and get the size.

vector<Speaker> Speakers;  // create the vector that holds Speakers
Speaker temp;  // make a speaker
Speakers.push_back(temp);  // this adds the speaker to the back of the vector.

Hi, NathanOliver,

Thanks for the help. But, I have to use c-strings. I was thinking about using string, but my instructor enforced to use c-strings only. so. That's why, I'm having a hard time.

Well if you have to use char arrays than you can just make the array large enough to handle most inputs or you can write a function to change the size of the array during run time.

Yea, that's what I thought of doing to. But I wasn't sure if that would be right. Thanks again. Appreciate the time.

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.