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");
}
}
}