Эротические рассказы

Beginning Programming with C++ For Dummies. Davis Stephen R.Читать онлайн книгу.

Beginning Programming with C++ For Dummies - Davis Stephen R.


Скачать книгу
from the many types of targets offered.

      2. Select Console Application and select Go.

      Code::Blocks responds with the display shown in Figure 2-12. Here Code::Blocks is offering you the option to create either a C or a C++ program.

      3. Select C++ and click Next.

      Figure 2-12: Select C++ as your language of choice.

      Code::Blocks opens a dialog box where you’ll enter the name and optional subfolder for your project. First, click the little … button to create a folder to hold your projects, and navigate to the root of your working disk (on a Windows machine, it’ll be either C or D, most likely C). Select the Make New Folder button at the bottom left of the window. Name the new folder Beginning_Programming-CPP.

      4. Click OK when your display looks like the one shown in Figure 2-13.

      

The folder that you create to hold your project must not contain any spaces in the name. In addition, none of the folders in the path should contain spaces. That automatically eliminates placing your projects on the Desktop since the path to the Desktop contains spaces. You should also avoid spaces in the name of the project. You can use underscores to separate words instead. The Code::Blocks compiler gets confused with spaces in the filenames and generates obscure and largely meaningless errors.

      Figure 2-13: Create the folder Beginning_Programming-CPP into which you’ll collect your C++ projects.

      Now enter the name of the Project as HelloWorld. Notice that Code:: Blocks automatically creates a subfolder of the same name to contain the files that make up the project.

      5. Click Next when your display looks like Figure 2-14.

      Figure 2-14: Call your first project HelloWorld.

      6. When Code::Blocks asks how you want your subfolders set up, you can accept the default configuration, as shown in Figure 2-15. Select Finish.

      

You can select the Back button to back up to a previous menu in the preceding steps if you screw something up. However, you may have to re-enter any data you entered when you go forward again. When you select Finish, you can no longer return and change your selections. (If you screw up and want to redo the project, you’ll first need to remove the Project: Right-click HelloWorld in the Management window and select Close Project. Now you can delete the folder Beginning_Programming-CPP\HelloWorld and start over again.)

      Figure 2-15: Select Finish on the final page to complete the creation of the HelloWorld Project.

Testing your default project

      Code::Blocks creates a console application project – and even populates it with a working program – when you select Finish on the Project Wizard. To see that program, click the plus (+) sign next to Sources in the Management window on the left side of the display. The drop-down list reveals one file, main.cpp. Double-click main.cpp to display the following simple program in the source code entry window on the right:

      #include <iostream>

      using namespace std;

      int main()

      {

      cout << "Hello world!" << endl;

      return 0;

      }

      It’s okay to skip over what some of this stuff means for now, but the crux of the program starts after the open brace following main(). This is where execution begins. The line

      cout << "Hello world!" << endl;

      says to output the line "Hello, world!" to the cout, which by default is the command line. The next line

      return 0;

      causes control to return to the operating system, which effectively terminates the program.

      1. Select Build⇒Build to build the C++ source statements into an executable machine language program.

      (You can press Ctrl+F9 or click the Build icon if you prefer.) Immediately, you should see the Build Log tab appear in the lower-right screen followed by a series of lengthy commands, as shown in Figure 2-16. This is Code::Blocks telling the C++ compiler how to build the test program using the settings stored in the project file. The details aren’t important. What is important, however, is that the final two lines of the Build Log window should be

      Process terminated with status 0 (0 minutes, 1 seconds)

      0 errors, 0 warnings

      The terminated status of 0 means that the build process worked properly. The “0 errors, 0 warnings” means that the program compiled without errors or warnings. (The build time of 1 second is not important.)

      

If you don’t get a status of 0 with 0 errors and 0 warnings, then something is wrong with your installation or with the project. The most common sources of error are

      ● You already had a gcc compiler installed on your computer before you installed Code::Blocks. Code::Blocks uses a special version of the GNU gcc compiler, but it will use any other gcc compiler that you may already have installed on your computer. Your safest bet is to uninstall Code::Blocks, uninstall your other gcc compiler, and reinstall Code::Blocks from scratch.

      ● You built your project in a directory that contains a space in the name; for example, you built your project on the Desktop. Be sure to build your project in the folder Beginning_Programming-CPP in the root of your user disk (most likely C on a Windows machine).

      Figure 2-16: Building the default program should result in a working program with no errors and no warnings.

      Конец ознакомительного фрагмента.

      Текст предоставлен ООО «ЛитРес».

      Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

      Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAQCAwMDAgQDAwMEBAQEBQkGBQUFBQsICAYJDQsNDQ0LDAwOEBQRDg8TDwwMEhgSExUWFxcXDhEZGxkWGhQWFxb/2wBDAQQEBAUFBQoGBgoWDwwPFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhb/wAARCALuAjIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgc
Скачать книгу
Яндекс.Метрика