Frequently Asked Questions
for
Beginning Programming with C++ for Dummies
Q: I bought "Beginning Programming with C++ for Dummies" in e-format. Is there some place that I can download the programs from the CD-ROM?
A: You can download the C++ source files from . The Beginning_Programming-CPP.zip file contains the source files along with the project files to compile them in Code::Blocks. The setup.exe is the version of Code::Blocks for Windows that came with the book. You can download other versions of Code::Blocks at.
Q: The first time I build my program with Code::Blocks I get the following error message: "...uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?! Skipping... Nothing to be done" What's wrong?
A: (Windows) The Code::Blocks package first installs the GNU C++ compiler. It then installs the Code::Blocks editor that looks for a compiler to connect to. If you already have a C++ compiler installed on your machine, Code::Blocks can find that other compiler instead of the one it installed.
There are two solutions. The best solution is to uninstall Code::Blocks and then uninstall the "other" C++ compiler. Finally reinstall Code::Blocks. Without the other C++ compiler, it should now find the proper compiler and work properly.
A second approach is to redirect Code::Blocks to the GNU C++ compiler. To do this, select "Settings" then "Compiler and Debugger...". From there, select the "Toochain executables" to C:\Program Files\CodeBlocks\MinGW (this is the default location where CodeBlocks installs the C++ compiler on a Windows machine).
Note:For Windows 7, the default path is C:\Program Files (x86)\CodeBlocks\MingGW.
You can easily check this yourself. Open Windows Explorer. Look in C:\Program Files\CodeBlocks or C:\Program Files (x86)\CodeBlocks. Then check for a subdirectory MingGW. If it's not there, then you didn't install the GCC compiler. If it is, look for a subdirectory bin that includes a ton of executables including gcc.exe.
Enter the proper path to the MingGW. You're display should look like the following.
Select OK to save the result and retry.
(Mac OS, Linux) The Code::Blocks package for Macintosh does not automatically install GCC - you'll have to do that yourself. However, there are instructions for doing that at. Once you've installed GCC, you can install Code::Blocks and it should work fine.
Q: The ForFactorial program in Chapter 10 doesn't generate the text described in the chapter. What am I doing wrong?
A: You aren't doing anything wrong. Originally that program had an outer loop that allowed the user to enter more than one number to take the factorial of. During the writing of the book, I removed the outer loop but forgot to update the chapter text. The following code includes the outer loop and generates the output specified in the chapter text:
//
// ForFactorial - calculate factorial using the for
// construct.
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
cout << "This program calculates factorials of user input.\n"
<< "Enter a negative number to exit\n";
while(true)
{
// enter the number to calculate the factorial of
int nTarget;
cout << "Enter a number to take factorial of: ";
cin >> nTarget;
// break if the number entered is negative
if (nTarget < 0)
{
break;
}
// start with an accumulator that's initialized to 1
int nAccumulator = 1;
for(int nValue = 1; nValue <= nTarget; nValue++)
{
cout << nAccumulator << " * "
<< nValue << " equals ";
nAccumulator = nAccumulator * nValue;
cout << nAccumulator << endl;
}
// display the result
cout << nTarget << " factorial is "
<< nAccumulator << endl;
}
// wait until user is ready before terminating program
// to allow the user to see the program results
system("PAUSE");
return 0;
}
Q: I have a question that doesn't appear here. What should I do?
A: E-mail me at and I will try to help.
Часто задаваемые вопросы
для
к программированию с C + + для чайников
Вопрос: Я купил «начала программирования на С + + для чайников" в электронном виде. Есть ли место, которое я могу скачать программы из CD-ROM?
А: Вы можете загрузить + + исходные файлы Си из . Файл Beginning_Programming-CPP.zip содержит исходные файлы вместе с файлами проекта, чтобы собрать их в Code :: Blocks. Setup.exe это версия Code :: Blocks для Windows, который пришел с книгой. Вы можете скачать другие версии Code :: Blocks на .
Вопрос: В первый раз я строить свою программу с Code :: Blocks я получаю следующее сообщение об ошибке:.?! "... использует недопустимый компилятора Вероятно, путь инструментарий в рамках опций компилятора не настроено правильно Пропуск ... Ничего быть сделано "Что случилось?
: (Windows) Пакет Code :: Blocks сначала устанавливает C + + компилятор GNU. Затем он устанавливает редактор Code :: Blocks, который ищет компилятор для подключения. Если у вас уже есть C + + компилятор установленной на вашем компьютере, Code :: Blocks можете обнаружить, что другой компилятор вместо той, которую она установлена.