line 1 error: iostream: No such file or directory
line 2 error: ctime: No such file ore directory
line 3 error: expected '=', ',', ';', 'asm' or '_attribute_' before 'namespace'
line 11 error: 'true' undeclared (first use in this function)
line 11 error: (Each undeclared identifier is reported only once
line 11 error: for each function it appears in.)
line 14 warning: implicit declaration of function 'system'
line 15 error: 'cin' undeclared (first use in this function)
line 18 warning: implicit declaration of function 'srand'
line 18 error: 'static_cast' undeclared (first use in this function)
line 18 error: 'insigned_int' undeclared (first use in this function)
line 18 warning: implicit declaration of function 'time'
line 19 warning: implicit declaration of function 'rand'
line 20 error: 'cout' undeclared (first use in this function)
line 20 error: 'endl' undeclared (first use in this function)
I don't understand what it's doing. Why doesn't it recognize iostream and ctime? It does that with some programs but not others.
What IDE are you using? It sounds to me like you don't have any libraries installed, or they can't be accessed. I'd say your best (fastest) bet would be to uninstall whatever IDE you're using and reinstall, making sure this time around all of your libraries are being installed.
All of your errors refer to functions and operators, which are defined in libraries and accessed through your include statements at the top of the page. Other than those, it seems like everything else is in order (both grammatically and semantically).
The weird thing is, it doesn't do that with the hello world program that the IDE came with. I can modify the file that the hello world was in and they work correctly, but when I try to create a new, empty, project this is what happens.
edit: I reinstalled Code::Blocks, but the same errors occur.
-------------- Build: Debug in Gumballs ---------------
mingw32-g++.exe -Wall -fexceptions -g -c "C:\Program Files\CodeBlocks\Gumballs\main.cpp" -o obj\Debug\main.o
C:\Program Files\CodeBlocks\Gumballs\main.cpp: In function 'int main()':
C:\Program Files\CodeBlocks\Gumballs\main.cpp:13: error: 'system' was not declared in this scope
C:\Program Files\CodeBlocks\Gumballs\main.cpp:17: error: 'srand' was not declared in this scope
C:\Program Files\CodeBlocks\Gumballs\main.cpp:18: error: 'rand' was not declared in this scope
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings
I don't know why the tutorial in the video worked without it. I didn't actually watch it, but it seems like it shouldn't have so I couldn't tell you there.
The reason you need it is like the computer was saying when you tried to compile the code, it couldn't figure out what srand, rand, and system were. As it turns out all of those are included in cstdlib, and thus when you included that the computer knew what to do.