I recently debugged my program for a sort of an Arduino 20Q game with animals, now when I try to verify the program it gives me a compiling error, I've never ran into this before.
Any ideas?
(I put my program in a ZIP file because it exceeds the 9000 character limit)
ErrorCompiling.zip (2.37 KB)
Forget about the Error Messages, here they are:
Arduino: 1.6.5 (Windows 7), Board: "Arduino Uno"
Goodchild_DE_Project.cpp.o: In function loop': C:\Program Files (x86)\Arduino/Goodchild_DE_Project.ino:321: undefined reference to
findLastAnimal()'
collect2.exe: error: ld returned 1 exit status
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Do you have a findLastAnimal() function in your program ?
How many bytes do those arrays take and could they be byte instead of int ?
Looks like you declared "char *findLastAnimal();" but did not define it anywhere.
@JohnWasser
I'm not sure how to define a char*, what I want it to do is when int countRemainingAnimals =1, I want findLastAnimal to display the name of the last value in the animals list
Ex: If the last animal is a dolphin, I want it to display "dolphin"
@UKHelibob I'm not sure how many memory the arrays take, is there any way to check? And other than the declaration of the char* and the SerialPrintln(findLastAnimal()); line of code (line 193), I have not written it anywhere else
when int countRemainingAnimals =1, I want findLastAnimal to display the name of the last value in the animals list
. You don't need to find the name because you know where it is from the number of entries in the array, which you can calculate.
char *anArray[] = {"Lion", "Zebra", "Goose", "Chicken"};
int lastArrayIndex = (sizeof(anArray) / sizeof(anArray[0])) - 1;
void setup()
{
Serial.begin(115200);
Serial.println(anArray[lastArrayIndex]);
}
void loop(){}
As to how much memory the arrays use you can calculate it yourself. How many bytes does each level take ? How many levels are there ? Or, as above, you can use sizeof(arrayName) to have it calculated for you.