Worse than that it doesn't compile :+) If you compile with cpp.sh (the gear icon top right of the code) with all 3 warnings on, you will see what I mean.
ARRSIZE is not defined anywhere. If defined in main it is not in scope for the functions, send it as an argument.
const std::size_t ARRSIZE = 100;
You need to declare your files correctly, currently they are not associated with any file, look at the example here:
Oh sorry. My program is a larger program that cplusplus won't allow, so ARRSIZE and all the #includes are in the original program. Sorry for that. My problem is that the
1 2 3
if (arr[datasize].type == "Dog") { //program does not go through this
cout << "Testing if statement" << endl;
}
won't run.
Dhayden. When I do run it, the datasize does say it is 1. Will datasize not being initialized cause that issue?
When I do run it, the datasize does say it is 1. Will datasize not being initialized cause that issue?
You just got lucky. The program doesn't define what the initial value should be. You could add or delete code and the value could suddenly change to some random appearing number. You need to initialize it.
To repeat myself, your if statement is looking at the wrong item in the array. You should look in arr[0] or arr[datasize-1] depending on whether you want the first or last item in the array.