Thread: help!!!!

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    7

    help!!!!

    Here's my problem. I've been trying to run this porgram forever and I CANT get this one error to fix!!!! What's wrong? (Sorry, its very long and ineffecient... work with me)


    Code:
    #include <iostream.h>
    #include <iomanip.h>
    #include <string.h>
    #include "CASHIER.H"
    #include "INVMENU.H"
    #include "BOOKINFO.H"
    
    
    
    
    void cashier(void)
    {
    	extern int arraySize;
    
    	extern char bookTitle[];   //these were originally in mainmenu.cpp, but had 
    	extern char isbn[];        //to move them here so that bookTitle could be found.
    	extern char author[];
    	extern char publisher[];
    	extern char dateAdded[];
    	extern int qtyOnHand[];
    	extern float wholesale[];
    	extern float retail[];
    	
    	char date[10], another, additional;
    	int books;
    	int quantity[50];
        //char isbn2[50];
    	char title[50][50];
    	float price[50];
    	float subtotal = 0, sub[50];
    	float total = 0;
    	float tax = 0;
    	const double TAX = .06;
    
    do
    {
    	cout << "How many different books are being purchased?   ";
    	cin >>books;
    	cout << "Please enter the date in MM/DD/YY format --> ";
    	cin >> date;
    	for (int count = 0; count < books; count++)
    	{
    	cout << "\nPlease enter the quantity of books being purchased --> ";
    	cin >> quantity[count];
    
    	cout << "\nPlease enter the ISBN number of the book being purchased --> ";
    	cin >> isbn[count];
    
    		cout << endl << endl;
    
    		for (int counter = 0; counter < 50; counter++)
    		{
    			if (isbn[counter] == isbn[count]) 
    			{
    				cout << endl << endl;
    				cout << bookInfo(isbn[count], bookTitle[count], author[count], publisher[count], dateAdded[count], qtyOnHand[count], wholesale[count], retail[count]);
    				cout << endl << endl;
    				break;
    			}
    		}
    
    	cin.ignore(); //because the getline function will accept the null terminator at the end of the previous cin if this is not place before it.
    	cout << "\nPlease enter the title of the book --> ";
    	cin.getline(title[count],50);
    
    	cout << "\nPlease enter the price of the book --> ";
    	cin >> price[count];
    
    	sub[count] = price[count] * quantity[count];
    	subtotal += sub[count];
    	tax += subtotal * TAX;
    	total += subtotal + tax;
    	}
    
    
    
    
    
    
    
    
    	cout << "\n\n\n\n\n\nSerendipity Booksellers\n\n";
    	cout << "Date:  "<< date << "\n\n";
    	cout << "Qty     ISBN        Title                                 Price        Total\n";
    	cout << "----------------------------------------------------------------------------\n\n\n";
    	
    	
    	for(count = 0; count < books; count++)
    	{
    
    	cout.precision(2);
    	cout.width(6); //the width function sets the amount of space for the upcoming set of characters or numbers.
    	cout.setf(ios::fixed|ios::showpoint|ios::left); //sets fixed point notation, shows decimal points and left justifies everything.
    
    	cout << quantity[count] << "  ";
    	cout.width(10);
    
    	cout << isbn[count] << "  ";
    	cout.width(36);
    
    	cout << title[count] << "  " ;
    	cout.width(10);
    
    	cout << price[count]<< "  ";
    	cout.width(15);
    	cout << sub[count];
    	cout << endl;
    	}
    	cout << "\n\n\n\n                    Subtotal  "<< subtotal << "\n";
    	cout << "                    Tax  "<< tax << "\n";
    	cout << "                    Total " << total << "\n\n\n\n";
    	
    
    	cout << "Would you like to process another transaction?  (Y/N)  ";
    	cin >> another;
    }
    while (another == 'y' || another =='Y');  //as long as the user enters y or Y, the program will contiue allowing for more transactions.
    
    
    	cout << "Thank you for shopping at Serendipity!\n\n\n\n";
    
    
    }

    Here's my error:

    error C2664: 'bookInfo' : cannot convert parameter 1 from 'char' to 'char []'
    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast



    And it happens here:

    Code:
    	if (isbn[counter] == isbn[count]) 
    			{
    				cout << endl << endl;
    			******RIGHT HERE -->  cout << bookInfo(isbn[count], bookTitle[count], author[count], publisher[count], dateAdded[count], qtyOnHand[count], wholesale[count], retail[count]);
    				cout << endl << endl;
    				break;
    			}

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    You are supposed to pass a char[], but you are passing just a single char.

    char name[32];
    in this example, just doing name in your code would be a char[]. Doing name[0] would be a single char, because you're accessing ONE char in the array of chars.

    So instead of passing isbn[count], just pass isbn. Or if you meant to only pass a char, change the function prototype from:
    int myfunc(char someVar[])
    to
    int myfunc(char someVar)
    Just apply that to your function, cuz I don't see the function prototype in your code anywhere, guessing it's in one of the .h files

    -hope that helps

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    7
    Okay, now I'm getting this error:

    --------------------Configuration: mainmenu - Win32 Debug--------------------
    Linking...
    cashier.obj : error LNK2001: unresolved external symbol "void __cdecl bookInfo(char * const,char * const,char * const,char * const,char * const,int * const,float * const,float * const)" (?bookInfo@@YAXQAD0000QAHQAM2@Z)
    cashier.obj : error LNK2001: unresolved external symbol "char (* bookTitle)[51]" (?bookTitle@@3PAY0DD@DA)
    invmenu.obj : error LNK2001: unresolved external symbol "char (* bookTitle)[51]" (?bookTitle@@3PAY0DD@DA)
    cashier.obj : error LNK2001: unresolved external symbol "char (* author)[31]" (?author@@3PAY0BP@DA)
    invmenu.obj : error LNK2001: unresolved external symbol "char (* author)[31]" (?author@@3PAY0BP@DA)
    cashier.obj : error LNK2001: unresolved external symbol "char (* publisher)[31]" (?publisher@@3PAY0BP@DA)
    invmenu.obj : error LNK2001: unresolved external symbol "char (* publisher)[31]" (?publisher@@3PAY0BP@DA)
    cashier.obj : error LNK2001: unresolved external symbol "char (* dateAdded)[11]" (?dateAdded@@3PAY0L@DA)
    invmenu.obj : error LNK2001: unresolved external symbol "char (* dateAdded)[11]" (?dateAdded@@3PAY0L@DA)
    cashier.obj : error LNK2001: unresolved external symbol "int * qtyOnHand" (?qtyOnHand@@3PAHA)
    invmenu.obj : error LNK2001: unresolved external symbol "int * qtyOnHand" (?qtyOnHand@@3PAHA)
    cashier.obj : error LNK2001: unresolved external symbol "float * wholesale" (?wholesale@@3PAMA)
    invmenu.obj : error LNK2001: unresolved external symbol "float * wholesale" (?wholesale@@3PAMA)
    cashier.obj : error LNK2001: unresolved external symbol "float * retail" (?retail@@3PAMA)
    invmenu.obj : error LNK2001: unresolved external symbol "float * retail" (?retail@@3PAMA)
    cashier.obj : error LNK2001: unresolved external symbol "char (* isbn)[14]" (?isbn@@3PAY0O@DA)
    invmenu.obj : error LNK2001: unresolved external symbol "char (* isbn)[14]" (?isbn@@3PAY0O@DA)
    Debug/mainmenu.exe : fatal error LNK1120: 9 unresolved externals
    Error executing link.exe.

    mainmenu.exe - 18 error(s), 0 warning(s)


    What the hell is that?!?!?

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    unresolved external symbol means that the compiler couldn't find what all those extern variables you declared should be.

    Did you forget a library file, another source code, etc?

  5. #5
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    Fill in the Blank:

    using namespace ______ ;
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  6. #6
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    #include <iostream> NOT #include <iostream.h>

    your using C++ libs, use C++ conventions as well

    and as was mentioned above, you have to specify what namespace your using.

    using namespace std;

Popular pages Recent additions subscribe to a feed