Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.

Similar presentations


Presentation on theme: "1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail."— Presentation transcript:

1 1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail

2 2 C++ Development Environment Microsoft vs Linux Visual C++ vs Borland C++ vs gcc IDE vs command line

3 3 Basics of a Typical C++ Environment Phases of C++ Programs: 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker links the object code with the libraries, creates a.out and stores it on disk Editor Preprocessor Linker CPU Primary Memory........................ Disk Files: *.cpp, *.c, *.h *.obj, *.exe

4 4 Editing

5 5 Compilation Compiler options Conditional compilation

6 6 Linking Linker options

7 7 Debugging Through debugger Through outputs

8 8 Compiler Errors Warnings Errors Fatal errors

9 9 Linker Errors

10 10 C++ Program Structure Head area Include area Prototype definitions Externs Constants area Global variable area Main function Other functions

11 11 Program Style Indenting Commenting Naming constants

12 12 Our First C++ Program /* Program #1 - A first C++ program. Enter this program, then compile and run it. */ #include // main() is where program execution begins. int main() { cout << “Hello, world!"; return 0; }

13 13 Some Exercises Put an extra space between the < and the iostream.h file name Omit one of the symbols in the include directive Omit the int from int main() Omit or misspell the word main Omit one of the(), then omit both the ()


Download ppt "1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail."

Similar presentations


Ads by Google