C++ HELL HELP ASAP

/***************Database of Student Records*****************
Name:Victoria Burroughs
Created: November 5th, 2003
Modified:
Description: Create a student database which will randomly search

Input:
Output:
/************************************************************/

#include //Library for input/output
#include //provides functions to manipulate,compare,search,tokenize strings
#include //parameterized stream manipulators
#include
using namespace std;//includes entire standard library of name definitions

const int DATABASE=20;
const int CHARACTERS=45;
int s=0;

void print();
void input();
void agesort();
void linearSearch ();
void namesort();
void printcountry(int t);


struct student
{
char name[CHARACTERS];
int SSN;
int AGE;
char address1[CHARACTERS];
char address2[CHARACTERS];
char address3[CHARACTERS];

};
void swap (student *, int pos1,int pos2 );
student records[DATABASE];

void main()
{
char ans;
char choice =' ';
void input();

do

{
cout<<"This is the student record database. Choose an option from the menu
";
cout<<"by typing in the appropriate number
";
cout<<"a. Sort all the records according to age and print the records.
";
cout<<"b. Sort all the records according to last name and print the records
";
cout<<"c Print the records in the currrent order.
";
cout<<"d Search the records for a student by country.
";
cout<<"e Exit the program.
";
cin>>choice;
switch(choice)//provides convenient notation for multiple else if tests
{
case 'a':
void agesort();
void print() ;
break;//terminates a loop and jumps out of it to the next statement

case 'b':
void namesort();
void print();
break;

case 'c':
void print();
break;

case 'd':
void linearSearch();
break;

case'e':
break;

default:
cout<<"Your input is invalid.
";
break;
}

cout<<"If you want to view menu again, select 1"<<endl;
cin>>ans;

}
while(ans!='e');
}

void agesort()
{
for(int j=DATABASE; j>=2; j--)
for(int k=0; k>records[s].AGE;
cout<<"Please enter the student's social security number.
";
cin>>records[s].SSN;
cin.ignore();
cout<<"Please enter the student's street address.
";
cin.getline(records[s].address1,CHARACTERS, '
');
cout<<"Please enter the city,state, and zip code.
";
cin.getline(records[s].address2,CHARACTERS, '
');
cout<<"Please enter the student's country.
";
cin.getline(records[s].address3,CHARACTERS, '
');
}


}


void print()

{
{
for (int s=0; s<20; s++)


cout<<records[s].name<<"
";
cout<<setw(4)<<records[s].AGE<<"-"<<setw(10)<<records[s].SSN<<"
";
cout<<records[s].address1<<"
";
cout<<records[s].address2<<"
";
cout<<records[s].address3<<"
";
}

void linearSearch()

{
int identical=0;
char key [CHARACTERS];
cin.ignore();
cout<<"
";
cout<<"Please enter the country you are looking for.
";
cin.getline(key,CHARACTERS, '
');

for(int t=0; t<20; t++)
{
if(strcmp(records[t].address3,key)==0
{
printcountry(t);
identical=identical+1;

}


if(identical!=0)
{
cout<<"
";
cout<<identical<<"matches were found
";

if (identical==0)
{
cout<<"
";
cout<<"No matches were found
";


}


void printcountry(int t)
{
cout<<"
";
cout<<"Student"<<(t+1)"
";
cout<<"
";
cout<<"NAME:"<<records[t].name<<"
";
cout<<"Social Security Number:"<<records[t].SSN<<"
";
cout<<"AGE:"<<records[t].AGE<<"
";
cout<<records[t].address1<<"
";
cout<<records[t].address2<<"
";
cout<<records[t].address3<<"
";
}
void namesort(void)

{
for(int j=DATABASE; j>=2; j--)
{
for(int k=0; k0)
{

student temp;
temp=records[k+1];
records[k+1]=records[k];
records[k]=temp;

}
}
}
}

}


}
}


}
}
This is a program i Created and i have two errors and cannot figure out for the life of me what is wrong can u help???
--------------------Configuration: database - Win32 Debug--------------------
Compiling...
database.cpp
D:database.cpp(143) : error C2601: 'print' : local function definitions are illegal
D:database.cpp(172) : error C2958: the left parenthesis '(' found at 'D:database.cpp(167)' was not matched correctly
Error executing cl.exe.

Comments

  • that's nice. Now what is your question?
  • : that's nice. Now what is your question?
    :
    [blue]When you code your program you have to follow certain layout of code:
    [code]
    // Put here function prototypes used inside main()

    // Put main() here

    // Put the code of the functions from section #1 here...
    [/code]
    Now, let's do some theory - what is a prototype? Answer: prototype is something like that:
    [code]
    rettype funcname (type1 param1, type2 param2, ...);

    where:
    rettype - is what function returning (void or int or whatever you need)
    funcname - name of your function
    type1 param1 - type and name of parameter #1
    type2 param2 - type and name of parameter #2
    the ';' at the end is very important!!!
    if it is not there - compiler goes to mental institution...
    [/code]
    Now, what is the implementation of the prototype? Very simple - COPYPASTE your prototype, remove ';' at the end and add "{}" scope of the code, like so:
    [code]
    int function () // See, no ';'
    { // Scope added.
    }
    [/code]
    Now, follow the same for your code - and you did not.
    Your code should be looking like so:[/blue][code]

    void prototype1 (...);
    void prototype3 (...);
    void prototype2 (...);

    int main ()
    {
    // use your functions here...
    return 0;
    }

    // Now functions themselves:
    void prototype1 (...)
    {
    }

    void prototype3 (...)
    {
    }

    void prototype2 (...)
    {
    }
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories