"Spar 1" for CPSC 1375

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Source code (or just code)

A list of commands typed into one or more text files

Release Configuration

Optimized for size and performance

Match the Operating System to the recommended IDE for that OS

Windows -- Visual Studio Linux -- Code::Blocks Mac -- Xcode

Debug Configuration

Designed to help you debug a program

When compiling with Microsoft Visual C++, you get a C1010 fatal error, with an error message like "c:\vcprojects\test.cpp(263) :fatal error C1010: unexpected end of file while looking for precompiled header directive"

This error occurs when the Microsoft Visual C++ compiler is set to use precompiled headers but one (or more) of your C++ code files does not #include "stdafx.h" or #include "pch.h" as the first line of the code file. Our suggested fix is to turn off precompiled headers, which we show how to do in lesson 0.7 -- Compiling your first program. If you would like to keep precompiled headers turned on, to fix this problem, simply locate the file(s) producing the error (in the above error, test.cpp is the culprit), and add the following line at the very top of the file(s): #include "pch.h" Older versions of Visual Studio use "stdafx.h" instead of "pch.h", so if pch.h doesn't resolve the issue, try stdafx.h. Note that for programs with multiple files, every C++ code file needs to start with this line. Alternatively, you can turn off precompiled headers.

The files we save our code in should have a .cpp extension

True

Running/Executing a program

When a computer program is loaded into memory and the hardware sequentially executes each instruction

When executing a program, the console window blinks and then closes immediately.

ensure the lines are near the top #include <iostream> #include <limits> Then add the following code std :: cin . clear ( ) ; // reset an error flags std :: cin . ignore (std :: numeric_limits < std :: streamsize > :: max ( ) ' '/n' ) ; // ignore any characters in the input buffer until we find an enter character std :: cin . get ( ) ; // get one more char from the user

Computer Program/Applcation

A set of instructions that the computer can perform in order to perform some task

Put in order these general steps to create and run a coding project

(This is the correct order) 1. Create a console project in your IDE 2. If there isn't one already, add a .cpp file to your project 3. Write your program 4. Compile the project 5. Run the project

Debug Configuration

Good for testing code performance

Debug Configuration

Used for writing a program

Put in order the steps you should take to fix compilation errors:

(This is the correct order)

Programming

The process of creating a program

Place the steps for C++ development in order

1. Define the problem that you would like to solve 2. Determine how you are going to solve the problem 3. Write the program 4. Link object files 5. Debug and return to step 4 6. Compile the program 7. Test program

List the 4 things an integrated development environment (IDE) will allow you to do as a programmer, in the order you would do them

1. Develop 2. Compile 3. Link 4. Debug

Differentiate between characteristics of lower-level languages and higher-level languages 1. Faster 2. Portable 3. More Readable 4. Require a lot of instructions to do a simple task

1. Lower level 2. Higher level 3. Higher level 4. Lower level

Match the terms with their definitions: 1. Object File 2. Linker 3. Portable 4. Library File 5. C++ Standard Library

1. Machine language file typically named name.o or name.obj, where name is the same name as the .cpp file it was produced 2. A program that takes all the object files generated by the compiler and combines them into a single executable program, links library files, and resolves cross-file dependencies. 3. Usable without major rework for different types of system 4. a collection of precompiled code that has been "packaged up" for reuse in other programs 5. An extensive library, core to C++, that provides additional functionality that you can use in your programs

C++ excels in situations where the following is needed:

1. Precise control over memory 2. High performance

Match whether the phrase is describing a rule, best practice, or warning: 1. Instruction you MUST do 2. Things you SHOULD do 3. Things you should NOT do 4. If you don't do this, your program won't work 5. Considered standard or highly recommend 6. Superior to other alternatives when there is one 7. Tend to lead to unexpected results

1. Rule 2. Best Practice 3. Warning 4. Rule? 5. Best Practice 6. Best Practice 7. Warning

What are the characteristics of a console project?

1. Runs on a Linux, Mac, or Windows Console 2. Reads input from the keyboard 3. Only prints text to the screen 4. Compiles to a stand-alone executable

Match the terms with their definitions 1. Bugs 2. Debugging 3. Source Code 4. Code Editor

1. Technical Defects 2. Removing Bugs 3. The programs we write using C++ instructions 4. An editor that is designed for programming

Match the terms with their definitions 1. Machine Code 2. Binary Digit/Bit 3. Portable

1. The limited set of instructions that a CPU can understand directly 2. Each individual 0 or 1 3. Usable without major rework for different types of system

Match the terms with their definitions 1. Assembler 2. High-Level Languages 3. Compiler 4. Interpreter

1. Translates assembly language into machine code 2. Programming languages designed to allow the programmer to write programs without having to be as concerned about what kind of computer the program will be run on 3. A program that reads source code and produces a stand-alone executable program that can then be run 4. A program that directly executes the instructions in the source code without requiring them to be compiled into an executable first

My program compiles but it isn't working correctly. What do I do?

Debug it! There are tips on how to diagnose and debug your programs later in chapter 3

Release Configuration

Designed for when you are releasing a program to the public

Release Configuration

Does not contain extra debugging information

When trying to use cin, cout, or endl, the compiler says cin, cout, or endl is an 'undeclared identifier'

First, make sure you have included the following line near the top of your file: #include <iostream> Second, make sure each use of cin, cout, and endl are prefixed by "std::' for example: std::cout << "Hello world!" << std::endl; If this doesn't fix your issue, then it may be that your compiler is out od date, or the install is corrupted. Try reinstalling and/or upgrading to th elatest version of your compiler.

I'm trying to use C++11/14/17/XX functionality and it doesn't work

If your compiler is old, it may not support these more recent additions to the language. In that case, upgrade your compiler. For modern IDEs/compilers, your compiler may be defaulting to an older language standard. We cover how to change your language standard in lesson 0.12 -- Configuring your compiler: Choosing a language standard.

When trying to use endl to end a printed line, the compiler says end1 is an 'undeclared identifier'

Make sure you do not mistake the letter l (lower case L) in endl for the number 1. endl is all letters. Make sure your editor is using a font that makes clear the differences between the letter lower case L, upper case i, and the number 1. Also the letter capital o and the number zero can easily be confused in many non-programming fonts

Debug Configuration

Normally the default configuration in an IDE

Hardware

The collection of physical part of a computer system

When I compile my program, I get a warnings about "Cannot find or open the PDB file"

This is a warning, not an error, so it shouldn't impact your program. However, it is annoying. To fix it, go into the Debug menu -> Options and Settings -> Symbols, and check "Microsoft Symbol Server".

When I compile my program, I get an error about unresolved external symbol _main or _Winmain@16

This means your compiler can't find your main() function. All programs must include a main () function. There are a few things to check: a)does your code include a function named main? b) Is main spelled correctly? c)When you compile your program, do you see the file that contains function main() get compiled? If not, either move the main() function to one that is, or add the file to your project (see lesson 2.8 -- Programs with multiple code files for more information about how to do this). d)Did you create a console project? Try creating a new console project.

It is good to treat compiler warnings as it they were errors and fix them right away

True

Debug Configurations

Turns off optimizations and makes your program slower and larger

Visual Studio gives the following error: "1MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)"

You've likely created a Windows graphical application rather than a console application. Recreate your project, and make sure to create it as a Windows (or Win32) Console project.

I ran my program and get a window but no output

Your virus scanner or anti-malware may be blocking execution. Try disabling it temporarily and see if that's the issue.


Set pelajaran terkait

Chap 21: cardiovascular assessment

View Set

Heimler's History AP World U2 Review

View Set

Essentials of Meteorology by Ahrens Chapter 1

View Set

Reading Plus: FROM HUMAN TO INSECT PART 2

View Set

Overview of the cytoskeleton., Actin, 8 types of actin proteins, Intermediate filaments, Microtubules, Myosin, Kinesin and Dynein, Cell Cycle 1, CDKs, Some Checkpoint info, G1/S transition and S phase, Mitosis and completion of division

View Set

rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

View Set