| | |
Using a struct array
![]() |
•
•
Join Date: Nov 2006
Posts: 2
Reputation:
Solved Threads: 0
Hello there. This is obviously my first post on DaniWeb, as I just found the site in searching for a solution to my issue. I've read over the site rules, as well as the forum rules regarding homework help.
Let me start out by saying I am not looking for an easy solution, or some one to do my work. I'm simply trying to figure out why I can't get this darn thing to compile =)
I'm using Visual C++ 2005 Express Edition, and have pretty much just started coding an end-of-chapter lab assignment.
The issue I'm running into has to do with passing an array of my pre-defined struct into another function. The following is my code.
The errors that I am receiving are:
Again, this is in the early construction phase, and I don't seem to be having a compiler error... The error seems to come at the linking stage.
Any help would be greatly appreciated. Also, this looks like an excellent site and source of information =) Glad I stumbled upon it.
Let me start out by saying I am not looking for an easy solution, or some one to do my work. I'm simply trying to figure out why I can't get this darn thing to compile =)
I'm using Visual C++ 2005 Express Edition, and have pretty much just started coding an end-of-chapter lab assignment.
The issue I'm running into has to do with passing an array of my pre-defined struct into another function. The following is my code.
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <iomanip> #include <string> using namespace std; struct menuItemType { string menuItem; double menuPrice; }; void getData(menuItemType menu[]); void showMenu(menuItemType menu[]); void printCheck(menuItemType menu[]); int main() { menuItemType menu[8]; getData(menu); return 0; }
C++ Syntax (Toggle Plain Text)
1>Compiling... 1>Breakfast.cpp 1>Linking... 1>Breakfast.obj : error LNK2001: unresolved external symbol "void __cdecl getData(struct menuItemType * const)" (?getData@@YAXQAUmenuItemType@@@Z) 1>C:\Documents and Settings\Luwigie\My Documents\Visual Studio 2005\Projects\Breakfast\Debug\Breakfast.exe : fatal error LNK1120: 1 unresolved externals
Any help would be greatly appreciated. Also, this looks like an excellent site and source of information =) Glad I stumbled upon it.
The link error is telling you that you forgot to code the function getData(). This is not a standard C function -- you have to write it yourself.
Last edited by Ancient Dragon; Nov 13th, 2006 at 11:00 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
You have done everything right thus far.. the only thing you haven't done, is to provide "function definitions" for your functions.
Below your main( ), go ahead and right up what each function is supposed to do. Here is some pseudo to get ye' started:
make sure each function prototype has an associated function definition and life will == good.
Below your main( ), go ahead and right up what each function is supposed to do. Here is some pseudo to get ye' started:
C++ Syntax (Toggle Plain Text)
void getData(menuItemType menu[]) { do stuff... .... .... }
Last edited by Clinton Portis; Nov 13th, 2006 at 11:01 pm.
•
•
Join Date: Nov 2006
Posts: 2
Reputation:
Solved Threads: 0
Wow. I appreciate the quick response guys.
This dawned on me right after I posted. Doh!
I don't know why throwing a struct definition made me throw everything I've learned thus far out the window :-|
I appreciate the prompt responses guys! Almost wish I could take down this thread out of embarrasment :rolleyes:
This dawned on me right after I posted. Doh!
I don't know why throwing a struct definition made me throw everything I've learned thus far out the window :-|
I appreciate the prompt responses guys! Almost wish I could take down this thread out of embarrasment :rolleyes:
![]() |
Similar Threads
- read a array of type struct (C)
- how to declare array of struct (C#)
- Swapping chars within an array (C++)
- struct array and enum problems (C++)
- Can you add pictures/sounds in a win32 console app? (C)
- struct dynamic 2d array alloc (C)
Other Threads in the C++ Forum
- Previous Thread: Blue Screen of Doom!
- Next Thread: Virtual functions
| Thread Tools | Search this Thread |
anyfile api array based binary bitmap c++ c/c++ char class classes code coding compile console conversion count delete deploy desktop developer directshow dll download draw dynamic dynamiccharacterarray email encryption error file forms fstream function functions game gdi+ givemetehcodez gnu graph gui homeworkhelp homeworkhelper http iamthwee ibm ifstream input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node number numbertoword output packing parameter pointer problem program programming project python random read recursion reference rpg string strings temperature template test text text-file tree url variable vector video visualc++ visualizationtoolkit win32 windows winsock word wordfrequency wxwidgets






