Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Mac OS X Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-01-2009, 01:57 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 148
rraagg is on a distinguished road
Default Passing in an Array of Structure. How to??

Hi, im new to c++
Learning it in xcode.
I'm having problems with the following concept:
- I have a Structure
- I have an Array of the Structure
- I'm trying to pass the a Pointer (which points at the Array of structure) to a function.
- Im getting all sorts of errors!!

See code (simple example of what im trying to do!) Please help

Code:
#include <iostream>

//Struc
struct Dog{ 
    char    DogName[10]; 
} ;

//Constants
#define kMaxDogs 12

//Function Dec
void    GiveDogsAName(struct Dog *);

//Globals
struct Dog gDogs[kMaxDogs];

//Main
int main (int argc, char * const argv[]) {

	GiveDogsAName(gDogs);
	
    return 0;
}

//Function
void    GiveDogsAName(struct Dog *(TheDogs)[kMaxDogs])
{
	int intCurrentDog;
	
	for (intCurrentDog=0; intCurrentDog<kMaxDogs; intCurrentDog++) {
		
		if (intCurrentDog == 0)
		{
			strcpy(TheDogs[intCurrentDog]->DogName,"toto");
		}
	}

}
rraagg is offline   Reply With Quote
Old 08-01-2009, 02:28 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 148
rraagg is on a distinguished road
Default

This is the error by the way!

"GiveDogsAName(Dog*)", referenced from:
_main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
rraagg is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 467
14 members and 453 guests
alexeir, David-T, Dj_kades, foslock, iAppDeveloper, jeroenkeij, Mijator, myach, pipposanta, QuantumDoja, robsmy, sacha1996, SLIC, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,928
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:28 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0