-2

I get an error of unresolved externals error LNK1120 and error LNK2019: unresolved external symbol "void __cdecl crt_acc(class std::basic_string,class std::allocator > * const,int)" (?crt_acc@@YAXQAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main C:\Users\user\documents\visual studio 2010\Projects\Programming Assignment\Programming Assignment\Programming Assignment.obj

How i need to solve this? Emergency...

[UPDATED CODE IS HERE]

int main ()
{
    //Declare Variable
    string car_num[10], car_brand[50], car_model[50], car_colour[50], car_year[10], car_eng_cap[10], car_tran[10], car_cost[100];//string array for account information
    string enter_acc_num,search_car;
    int menu, cnt=0, check=0;
    int menu2;
    char selection;

    start_menu();//Run the Start Menu Function
    do
    {
        size_t count=0;//put into a loop to refresh back to 0 everytime
        read_data_file(car_num, car_brand, car_model, car_colour, car_year, car_eng_cap, car_tran, car_cost);//Run read data file function (it update the array everytime when it in the loop)
        for(size_t i=0; i<sizeof(car_num)/sizeof(*car_num); i++)//Small loop to identify the size of array car_num[10]
        {
            if(car_num[i]!="")
                count++;
        }
        cnt=count;
        system("cls");//Clear the screen
        cout<<"\n\tMENU"<<endl;
        cout<<"//////////////////////////////////////////////////"<<endl;
        cout<<"\n\t01. \tCREATE A NEW CAR ACCOUNT"<<endl;
        cout<<"\n\t02. \tEDIT A CAR ACCOUNT"<<endl;
        cout<<"\n\t03. \tREMOVE A CAR ACCOUNT"<<endl;
        cout<<"\n\t04. \tSEARCH A CAR "<<endl;
        cout<<"\n\t05. \tCHECK TOTAL INVENTORY"<<endl;
        cout<<"\n\t06. \tEXIT"<<endl;
        cout<<"\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"<<endl;
        cout<<"\tSelect Your Option(1-6)";
        cin>>menu; //User enter the selection (1-6)
        system("cls");//Clear the screen
        //Selection
        switch(menu)
        {
        case 1://User has select option 1
            {
            crt_acc(car_num, cnt);//Pass to create account function
        }
        break;
        case 2://User has select option 2
            {
                cout<<"\nEnter car registration number:";
                cin>>enter_acc_num; //Identify which account to be edited
                    check=enter_acc_num.length();
                    if(check<=8)
                    {
                        edit_account(enter_acc_num, car_num, car_brand, car_model, car_colour, car_year, car_eng_cap, car_tran, car_cost, cnt);//Pass to edit account function
                    }
                    else
                        cout<<"Please enter a valid car registration number."<<endl; //Inform user to enter a valid number
            }
            break;


        case 3://User has select option 3
            {
                cout<<"\nEnter car registration number:";
                cin>>enter_acc_num;//Identify which account to be deleted
                check=enter_acc_num.length();//Constraint for input
                if(check<8)
                {
                    for(int x=0; x<cnt; x++)
                    {
                        if(enter_acc_num==car_num[x])
                        {
                            cout<<"Are you sure want to remove the car account? (Y/N) "; //Ask user if really want to remove the account
                            cin>>selection;
                            switch(toupper(selection))
                            {
                            case'Y':
                                {
                                    remove_account(enter_acc_num, car_num, car_brand, car_model, car_colour, car_year, car_eng_cap, car_tran, car_cost, cnt);//Pass to delete account function
                                    cout<<"The Car Account successfully deleted."<<endl;
                                }
                                break;
                            case 'N':
                                {
                                    cout<<"Operation has been canceled, back to menu screen."<<endl; //Nothing will happen if user choose no option for remove account
                                }
                                break;
                            }
                        }
                    }
                }
                else
                    cout<<"Please enter a valid car registration number!"<<endl; //Inform user to enter a valid number
            }
            break;
        case 4: //Option 4
            {
                cout<<"Which field you want enter to search a car:"<<endl;//Ask user enter which field want to search car
                cout<<"\t01. Car Brand"<<endl;
                cout<<"\t02. Car Model"<<endl;
                cout<<"\t03. Year of Manufacturing"<<endl;
                cout<<"\t04. Price"<<endl;
                cout<<"\t05. Cancel"<<endl;
                cout<<"Which Option (0-5)?"<<endl;
                cin>>menu2;
                switch(menu2)
                {
                case 1: //Option 1
                    {
                        cout<<"Enter Car Brand:"<<endl;
                        cin>>search_car; //Identify which car brand to be search
                        for(int x=0; x<cnt; x++) //Loop to last account, by using cnt we can stop when the array is a null
                        {
                            if(search_car==car_brand[x])//Detecting which car brand same as user input
                            {
                                cout<<"\n\tCar Registration Number:"<<car_num[x]<<endl;
                                cout<<"\n\tCar Make or Brand:"<<car_brand[x]<<endl;
                                cout<<"\n\tCar Model:"<<car_model[x]<<endl;
                                cout<<"\n\tCar Colour:"<<car_colour[x]<<endl;
                                cout<<"\n\tYear of Manufacturing:"<<car_year[x]<<endl;
                                cout<<"\n\tEngine Capacity:"<<car_eng_cap[x]<<"cc"<<endl;
                                cout<<"\n\tTransmission:"<<car_tran[x]<<endl;
                                cout<<"\n\tCost of Car: RM"<<car_cost[x]<<endl;
                            }
                            else
                                cout<<"No data is founded."<<endl;
                            break;
                        }
                    }
                case 2: //Option 2
                    {
                        cout<<"Enter Car Model:"<<endl;
                        cin>>search_car; //Identify which car model to be search
                        for(int x=0 ; x<cnt ; x++)
                        {
                            if(search_car==car_model[x])//Detecting which car model same as user input
                            {
                                cout<<"\n\tCar Registration Number:"<<car_num[x]<<endl;
                                cout<<"\n\tCar Make or Brand:"<<car_brand[x]<<endl;
                                cout<<"\n\tCar Model:"<<car_model[x]<<endl;
                                cout<<"\n\tCar Colour:"<<car_colour[x]<<endl;
                                cout<<"\n\tYear of Manufacturing:"<<car_year[x]<<endl;
                                cout<<"\n\tEngine Capacity:"<<car_eng_cap[x]<<"cc"<<endl;
                                cout<<"\n\tTransmission:"<<car_tran[x]<<endl;
                                cout<<"\n\tCost of Car: RM"<<car_cost[x]<<endl;
                            }
                            else
                                cout<<"No data is founded."<<endl;
                            break;
                        }
                    }
                case 3: //Option 3
                    {
                        cout<<"Enter Year of Manufacturing:"<<endl;
                        cin>>search_car;
                        for(int x=0; x<cnt; x++)
                        {
                            if(search_car==car_year[x])//Detecting which car manufacturing year same as user input
                            {
                                cout<<"\n\tCar Registration Number:"<<car_num[x]<<endl;
                                cout<<"\n\tCar Make or Brand:"<<car_brand[x]<<endl;
                                cout<<"\n\tCar Model:"<<car_model[x]<<endl;
                                cout<<"\n\tCar Colour:"<<car_colour[x]<<endl;
                                cout<<"\n\tYear of Manufacturing:"<<car_year[x]<<endl;
                                cout<<"\n\tEngine Capacity:"<<car_eng_cap[x]<<"cc"<<endl;
                                cout<<"\n\tTransmission:"<<car_tran[x]<<endl;
                                cout<<"\n\tCost of Car: RM"<<car_cost[x]<<endl;
                            }
                            else
                                cout<<"No data is founded."<<endl;
                            break;
                        }
                    }
                case 4: //Option 4
                    {
                        cout<<"Enter Car Price:"<<endl;
                        cin>>search_car;
                        for(int x=0 ; x<cnt; x++)
                        {
                            if(search_car==car_cost[x])//Detecting which car price same as user input
                            {
                                cout<<"\n\tCar Registration Number:"<<car_num[x]<<endl;
                                cout<<"\n\tCar Make or Brand:"<<car_brand[x]<<endl;
                                cout<<"\n\tCar Model:"<<car_model[x]<<endl;
                                cout<<"\n\tCar Colour:"<<car_colour[x]<<endl;
                                cout<<"\n\tYear of Manufacturing:"<<car_year[x]<<endl;
                                cout<<"\n\tEngine Capacity:"<<car_eng_cap[x]<<"cc"<<endl;
                                cout<<"\n\tTransmission:"<<car_tran[x]<<endl;
                                cout<<"\n\tCost of Car: RM"<<car_cost[x]<<endl;
                            }
                            else
                                cout<<"No data is founded."<<endl;
                            break;
                        }
                    }
                case 5: //Option 5
                    {
                        cout<<"Operation Canceled."<<endl;
                        break;
                    }

                }
                }
                case 5: //Option 5
                    all_inventory(car_num, car_brand, car_model, car_colour, car_year, car_eng_cap, car_tran, car_cost,cnt);
                    break;
                case 6: //Option 6
                    {
                        cout<<"\n\nGOOD BYE!";
                        break;
                    }
                default:cout<<"\a";
                    }
cin.ignore();
cin.get();
    }while(menu!=6);
    return 0;
}

[Updated]

//Function Prototype (I put this between namespace and int main)

void start_menu();
void read_data_file(string a[], string b[], string c[], string d[], string e[], string f[], string g[], string h[]);
void crt_acc(string car_num[],int cnt);
void check_car_num(string car_num[], string &car_num1, int cnt);
void remove_account(string enter_acc_num, string car_num[], string car_brand[], string car_model[], string car_colour[], string car_year[], string car_eng_cap[], string car_train[], string car_cost[], int cnt);
void edit_account(string enter_acc_num, string car_num[], string car_brand[], string car_model[], string car_colour[], string car_year[], string car_eng_cap[], string car_tran[], string car_cost[], int cnt);
void all_inventory(string car_num[], string car_brand[], string car_model[], string car_colour[], string car_year[], string car_eng_cap[], string car_tran[], string car_cost[], int cnt);

[updated]

void crt_cc(string car_num[],int cnt) {

//Declare Variables

ofstream outfile;

string car_num1, car_year ,car_eng_cap, car_cost, car_model, car_brand, car_colour;

char car_tran;

check_car_num(car_num, car_num1, cnt);//Pass to check car registration number function

cout<<"\n\tEnter Car Make or Brand (Honda/Toyota/Proton/Perodua/Suzuki):";

cin>>car_brand;

cout<<"\n\tEnter Car Model :";

cin>>car_model;

cout<<"\n\tEnter Car Colour :";

cout<<"\n\tEnter Year of Manufacturing :";

cin>>car_year;

cout<<"\n\tEnter Engine Capacity(in CC) :";

cin>>car_eng_cap;

cout<<"\n\tEnter Car Tranmission (Auto(A)/Manual(M)):";

cin>>car_tran;

car_tran=toupper(car_tran);

cout<<"\n\tEnter Cost of the Car(RM) :";

cin>>car_cost;

cout<<endl;

cout<<"\n\tA Car Account Has Been Created. "<<endl;

cout<<"\n\tThe"<<car_brand<<car_model<<"has been created."<<endl;

//Write the new account data into file

outfile.open("caracc.txt",ios::app);

outfile<<car_num1<<endl;

outfile<<car_brand<<endl;

outfile<<car_model<<endl;

outfile<<car_colour<<endl;

outfile<<car_year<<endl;

outfile<<car_eng_cap<<endl;

outfile<<car_tran<<endl;

outfile<<car_cost<<endl;

outfile.close();//Close file
}
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Hollow Looi
  • 57
  • 1
  • 7
  • 2
    You did not provide enough information to solve your problem, but see [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) for a description of the problem and possible causes. Basically, you called a function called `crt_acc` but did not provide a definition. – Raymond Chen Aug 26 '14 at 15:13
  • provided code already – Hollow Looi Aug 26 '14 at 15:18
  • Where is the function `void crt_acc(string, int)` declared and defined? – atkins Aug 26 '14 at 15:23
  • it declared between int main() and Library and defined after return 0 – Hollow Looi Aug 26 '14 at 15:26
  • Your function definition is for `void crt_cc()` not `void crt_acc()`! Are you bothering us with a simple typo? – πάντα ῥεῖ Aug 26 '14 at 15:49
  • You forgot to simplify the program. Keep deleting code until you find the smallest program that still has the problem. See http://www.sscce.org/ – Raymond Chen Aug 26 '14 at 16:22

1 Answers1

3

You did not show where function crt_acc used in the statement below is declared and is defined

   case 1://User has select option 1
        {
        crt_acc(car_num, cnt);//Pass to create account function

But it seems you did not include in the build the object file where the function is defined.

EDIT:

As you updated your code then now it is seen that you defined function

void crt_cc(string car_num[],int cnt)

but call function

crt_acc(car_num, cnt);

I think there is a typo in your code.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
  • @Hollow Looi Where is the function defined? You have to include the corresponding module in the result build. – Vlad from Moscow Aug 26 '14 at 15:39
  • You mean the void function? I defined at bottom after return 0 – Hollow Looi Aug 26 '14 at 15:46
  • @Hollow Looi See my updated post. – Vlad from Moscow Aug 26 '14 at 16:04
  • thanks it solve my problem...but i have question...how do i change a string value all become uppercase.....and how to change the character front in the string become uppercase... – Hollow Looi Aug 26 '14 at 18:07
  • @Hollow Looi You need to use function std::toupper declared in header cctype. For example s.front() = std::toupper( s.front() );. If you want to convert all letters of a string then you have to use either a loop or some standard algorithm as for example std::for_each or std::transform – Vlad from Moscow Aug 26 '14 at 18:44
  • but it said that IntelliSense: no suitable conversion function from "std::string" to "int" exists – Hollow Looi Aug 26 '14 at 18:55
  • @Hollow Looi I wrote exactly how the task can be done. So it is obvious that you are doing something wrong. Use a loop. – Vlad from Moscow Aug 26 '14 at 19:02
  • s.front() = std::toupper( s.front() ); what the bracket do? – Hollow Looi Aug 26 '14 at 19:44
  • @Hollow Looi front() is a member function of class std::string that returns reference to the first character of a string. So if you need to have the first character of a string in upper case you can write s.front() = std::toupper( s.front() ); It is equivalent to s[0] = std::toupper( s[0] ); – Vlad from Moscow Aug 26 '14 at 19:48
  • sudden i get a window tab out said Unhandled exception at 0x775015de in Programming Assignment.exe: 0xC0000005: Access violation writing location 0x51821db9. what are those – Hollow Looi Aug 26 '14 at 20:23