Going over a program in a book to learn FOR loops. Just a basic counting program. For some reason I am getting error C2065 'i': undelcared identifier/IntelliSense: identifier "i" is undefined. It works for the first 2 in the code but the third one isnt working. When I take out that part of the code the program still doesnt work. I feel like I am missing something but dont really know what. Any thoughts?
That being said it still doesn't run. I get this:
'CounterProgram.exe' (Win32): Loaded 'C:\Users\Houston\Desktop\C++ Projects\CounterProgram\Debug\CounterProgram.exe'. Symbols loaded.
'CounterProgram.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'CounterProgram.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'CounterProgram.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'CounterProgram.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Cannot find or open the PDB file.
'CounterProgram.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
The thread 0x15e0 has exited with code 0 (0x0).
The thread 0x2960 has exited with code 0 (0x0).
The thread 0x3670 has exited with code 0 (0x0).
The program '[14860] CounterProgram.exe' has exited with code 0 (0x0).
I have compiled other programs. Many. I am 1/4 through the book. (not saying that to sound snarky, just to give an idea of how man). I added your suggestion and the pause worked perfectly. I guess it was just running so fast I thought it was bugging. Thank you to everyone for your help. Another not is, just to see what happened I didnt add the library and it still worked. It also worked with the library so that didnt break anything. Just thought I would let everyone know what I did. Thank you again! So helpful and GREATLY appreciated. *hope I spelled that right* <bad english
add the system ("pause"); at the end of your code instead of return 0;
Not to argue the issues of using system("pause");, but you should have both.
The system call will return, therefore the program should issue a return 0 to return control to the OS.
The newer C++ specifications stipulate that the compiler must provide a return 0; if the user does not provide one, but IMO, it is still a good practice to provide the return 0. The OP does not indicate if he is running on a newer compiler or not.