Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,911 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,207 people online right now. Registration is fast and FREE... Join Now!




Using Array of strings

 
Reply to this topicStart new topic

Using Array of strings, Write a C++ menu driven program for student database

desire2be
10 Dec, 2007 - 03:47 PM
Post #1

New D.I.C Head
*

Joined: 10 Dec, 2007
Posts: 2


My Contributions
CODE

//
//if select Math or SCIE as a major display all studrec associated
//studentidandmajor ex 3333MATH or 4445SCIE

#include<iostream>
#include<fstream>
#include<string>


//Function declaration
void PutMenu();
void GetData(int *, const char *);
//void DisplayMajor(int[], string[]);
int MenuChoice();
using namespace std;
//    This program implements an interactive menu with the
//  following options:

//   1 - Add records to the file
//   2 - Display student records for a major
//   3 - Exit from the program


int student_ID[4];
const char major_Code[4];

void main()
{
    
    
    //open output file
    ofstream fout;
    fout.open("C://student.txt");
    if (fout.fail())
    {
        cerr << "Output file opening failed.\n";
        exit(1);
    }
    
    
    MenuChoice();
    int choice, a[4];
    string b;        
    
    do  //Repeat procedure until choice is 3
    {
        
        
        PutMenu();
        choice = MenuChoice();
        switch (choice)
        {
        case 1:
            GetData(a, B);
            break;
        case 2:
//            DisplayMajor(student_ID, major_Code);
            break;
        case 3:
            exit(1);
        default:
            cout << "Invalid choice..." << endl;
          
        
        }
    } while (choice != 3);



}//  end main function;

// Gets data for the student id and Major
void GetData(int student_ID[], const *char major_Code[])
{
  int a;
  int b;
    
    
   char *major_CodePtra = "MATH";
   char *major_CodePtrb = "SCIE";
  

  cin >> a;
  cin >> b;
  
}



void PutMenu()
{
    cout << "MENU" <<endl;
    cout << endl << endl <<endl;
    cout << "  1 - Enter ID and Enter Major (CINS or CMSC)\n";
    
    cout << "  2 - Enter Major Code to display all student records with that code:\n";
    
    cout << "  3 - Exit and save records to file\n";
}
int MenuChoice()
{

    cout << "choice: ";
    int ch;
    cin >> ch;

    switch (ch)
    {
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    }
}

*edit: Please use code tags in the future. Thanks! code.gif

This post has been edited by Martyr2: 10 Dec, 2007 - 04:01 PM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Using Array Of Strings
10 Dec, 2007 - 04:01 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Btw... did you have some sort of question? What is it that you want help with? Thanks again. smile.gif
User is offlineProfile CardPM
+Quote Post

desire2be
RE: Using Array Of Strings
10 Dec, 2007 - 05:15 PM
Post #3

New D.I.C Head
*

Joined: 10 Dec, 2007
Posts: 2


My Contributions
[quote name='Martyr2' date='10 Dec, 2007 - 05:01 PM' post='288012']
Btw... did you have some sort of question? What is it that you want help with? Thanks again. smile.gif
["I need to write menu driven C++ program. I am confused about how to use pointer, string and arrays. The functions do not work" /quote]

User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Using Array Of Strings
11 Dec, 2007 - 05:54 AM
Post #4

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,351



Thanked: 51 times
Dream Kudos: 25
My Contributions
Can you please provide:

1. Exact error messages you are receiving from the compiler.
2. A complete description of what you mean by 'not working', including desired behaviour and actual behaviour.

User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 01:51PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month