C++ Programming

Time & Place
Wednesday 08:10-11:00, (H-103 [94334493])
TAs: cs101-ta-2018
Students enrolled in this class
Deitel C++ How to Program
Ivor Horton's Beginning Visual C++ 2013

Programming Environment

Tips for PuTTY

  1. Why doesn't the keypad work as expected? It keeps sending an escape sequence.
    Ans: These confusing things happen when PuTTY is in "application keypad mode".  Please follow the following steps:
    1. Bring up PuTTY Configuration.
    2. In the left pane, select Terminal - Features.
    3. Put a check mark next to "Disable application keypad mode".
  2. In the "ee" editor, If you want to move a line to somewhere else:
    1. Press Ctrl-K to cut the line
    2. Use cursor key to move to where you want to insert the line
    3. Press Ctrl-L
  3. In the "nano" editor, if you want to move a line to somewhere else:
    1. Press Ctrl-K to cut the line
    2. Use cursor key to move to where you want to insert the line
    3. Press Ctrl-C to paste the line

Tips for Visual C++

  1. Tools - Options - Text Editor - C++
  2. Help source choices can be changed in the Options dialog box under /Help/Online.
  3. Comments a block of code: Ctrl+K Ctrl+C.
  4. Uncomments a block of code: Ctrl+K Ctrl+U.
  5. Reformat a block of code: Ctrl+K Ctrl+F
  6. Project Properties (Alt-F7) - C/C++ - Preprocessor - Preprocessor Definition
  7. error C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead.
  8. If you cannot find the "Resource View":
  9. View the assembly code generated by Visual C++


  1. My C++ program can be compiled, but clang++ shows lots of warning: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
    You may compile with the option
    "clang++ -Wno-deprecated-writable-strings a.cpp".
  2. On my personal computer, I got an error message "LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt".
    Solution: Install Microsoft Visual Studio 2010 Service Pack 1.
  3. DreamSpark FAQ
  4. How could I connect to the STU.ipv6.club.tw server if I am not inside the campus?
  5. Q: Why can't I type Chinese characters in my editor?
    A: If you are using the "ee" editor, its support for Chinese is incomplete at this moment (until somebody fixs it up). Please try to use "nano" or "vim".
  6. Q: Why can't I create a new project in Visual Studio 2013 in the computer classroom (H-103)?
    A: The administrator did not configure Visual Studio 2013 well, so you will fail to create a new project because of the directory access permission.
    Solution: When you create a new project, change the "Location" to "C:\Users\xxx\Documents\Visual Studio 2013\Projects\". This is the correct path for you to create projects.
    Create Project
  7. Stack Overflow is a question and answer site for professional and enthusiast programmers.
  8. C++ FAQ Lite

Code Writing

  1. Draw a flowchart or write a pseudo code to illustrate the basic idea
  2. Prepare a test case so that after your code is complete, you may verify its correctness.
  3. Keyin your code and check it is correct or not.
  4. If the outcome differs from what you expect, ask yourself why.
  5. For rules about indentation, see GNU Coding Standards.  You may try tools like SourceFormatX Code Formatter.

How will your programming assignments be evaluated



Hands-On Exercise
Extended Reading
More Exercises
Week 1 2/22
Chapter 2: Data, Variables, and Calculations
Quiz 1
  1. Create Mail Filters
  2. Writing C Programs on a FreeBSD server.
  3. In which year were you born?
  4. [CPP01] Volume and surface area of a sphere
  5. [CPP02] Solving Linear Equations
  6. How to submit your homework?
Bash Guide for Beginners
Top 5 Best Linux Text Editors
MIT's Food Computer: The Future of Urban Agriculture?
New report details the prices within the cybercrime market
Top Time Management Apps for Students in 2015
Who are the hackers?
How Hacking, `Phishing' Works video
Google Science Fair
Try, Try Again

Offenbach: 霍夫曼的故事 - 船歌 (Barcarolle)video
  1. [CFP01] 雞兔同籠
  2. [CFP02] BMI (body mass index)
  3. [CFP03] What day is January 1st?
Week 2 3/1
Chapter 3: Decisions and Loops
Quiz 2

  1. [CPP03] Fibonacci sequence
  2. [CPP04] Sum of integers
  3. [CPP05] Prime Number Test
  4. [CPP06] Prime Numbers <= N
  5. [CPP07] Print the calendar of January
  6. Draw IO: Free Online Drawing
  7. Gliffy: Online Flowchart Software
  8. Easy flow chart creation with Dia
  9. How to Create a Flow Chart in Microsoft Word
  10. [YouTube] Drawing Flowcharts with Google Drawings
Goto statemetn considered harmful
What most schools don't teach video (Code.org video)
Let's teach kids to code video
Checking the Graphics Card Specifications on Your Computer

  1. [CFP04] Syracuse sequence
  2. [CFP05] Truth Table
  3. [CFP06] 9x9 Multiplication Table
  4. [CFP07] P → Q
  5. [CFP08] Beginning day of a month
  6. [CFP09] Calendar of a month
  7. Print the calendar of a year

Week 3 3/8
Math Library (Reference, PPT)
Time Library (Reference)
Ncurse Library (Tutorial, PPT)
Quiz 3
  1. [Moodle] Prime Numbers with sqrt()
  2. Plot cos(x) with characters
  3. Multiply Exercise * 10
  4. [Moodle] Move Around
Steamed: Valve Software Battles Video-game Cheaters
Bitcoin Solves a Huge Problem for the Global Economy
Microsoft Skips Windows 9, Reveals Windows 10
Week 4 3/15
Chapter 4: Arrays and Strings
String Manipulation
Quiz 4
  1. [CPP08] Dice Rolling
  2. [CPP09] Matrix Multiplication
  3. [CPP10] Caesar Cipher
  4. [CPP11] Delete Spaces in a String
  5. [CPP12] White Spaces
  6. Running Q
  7. Sokoban (1) - Level Format
UK teenager jailed for not disclosing password
The Real Threat to Economic Growth Is the Digital Divide
How to develop seamlessly in the cloud
[TED] Amy Cuddy: Your body language may shape who you are
Week 5 3/22
Chapter 4: Pointers

Quiz 5
  1. [CPP13] Exchange Sort
  2. [CPP14] Exchange Sort (2)
  3. Ex4_09 - *(primes + i) == primes[i]
  4. [EX14] Prime Numbers with an Array

  1. 15 Windows Utilities You Can't Live Without
  2. Multitasking
  3. [BBC] Academic Listening Part 2 - Lectures: Introduction

Week 6 3/29 Midterm Exam (1)

Week 7
4/5 溫書假

Microsoft's 'Spartan' browser will replace IE
The next 5,000 days of the webvideo
How to Build a Website
How to Download and Watch Free Movies Online Legally

Week 8
4/12  Chapter 5: Introducing Structure into Your Programs Quiz 6
Five reasons why Windows 8 has failed
Why Windows 8 Has Been Slow to Capture Consumer Mindshare
Why Gmail Services Aren't Free
Simon Sinek: How great leaders inspire actionvideo
  • People don't buy what you do; they buy why you do it.
  • Law of Diffusion

Week 9
4/19 Chapter 6: More about Program Strucutre
Function Pointers and Callback Functions
Quiz 7 Sherry Turkle: Connected, but alone?video
Google doesn't care where you went to college
Hacker Lexicon: What Are White Hat, Gray Hat, and Black Hat Hackers?
RFC 1855 - Netiquette Guidelines
Week 10 4/26
Quiz 8
Quiz 9
  1. EX7_01.cpp
  2. Addition of Rational Numbers (1)
  3. Addition of Rational Numbers (2)
  4. [CPP15] HW: sort rational numbers (q/p)
  5. struct tm
  6. [CPP16] storeListReversely
  7. [CPP17] storeList
John Underkoffler points to the future of UIvideo
TED blends animation with education at new website
First Look: Inside the Army’s App Store for War
MIT Creates Amazing UI From Levitating Orbs
ZeroN - Levitated Interaction Element video
  1. Addition of Rational Numbers (3)
  2. [CFP22] Astrological Sign (2)
  3. [Moodle] Shuttle Bus
  4. [CFP23] insertToList
  5. [CFP24] Insert to Binary Tree
Week 11 5/3
Chapter 6: Exception Handling (P.229)
FreeBSD Socket Programming
Beej's Guide to Network Programming
Programming Windows TCP Sockets in C++ for the Beginner
Chapter 7: Classes and Constructors
Quiz 10
  1. Matrix (1)
  2. Matrix (2)
  3. Matrix (3)
  4. Determinant (2)
  5. HW: Horse Racing (3)
The Sound of Rainingvideo
世界上最辛苦的工作 - World's Toughest Jobvideo
How to measure Windows 7 memory usage
10 Tips to Become a Better Presentervideo
The Mobile Phone in Developing Nations
BASIC Turns 50, and I Still Miss It

  1. Reduction of Rational Numbers
  2. Copy Constructor
  3. Wireshark
  4. Show Name (1)
  5. [CFP25] Show Name (2)
Week 12 5/10
Chapter 8: Destructor, Operator Overloading

Quiz 11
  1. EX: Matrix (4)
  2. EX: Matrix (5)
  3. Linked List
  4. Sort Rational Numbers
  5. Horse Racing (4)
  6. TETRIS (7)
  7. TETRIS (8)
Analyst's View: PDF - Pretty Dangerous Format?
The Story behind LINE App Development
Asian Mobile App LINE Opens its API
57 Chat APIs: Skype, MSN Messenger and Google Talk
  1. [CFP26] Sort Name (1)
  2. [CFP27] Sort Name (2)
  3. EX: Matrix (6)
  4. EX: Matrix (7)
  5. EX: Matrix (8)
  6. EX: Matrix (9)
  7. [CFP28] Matrix (10)
Week 13 5/17
Quiz 12
  1. [CPP18] Rational (7)
  2. [HW05] Determinant (3)
    [EX34] Input File Stream
  3. Inverse
  4. TETRIS (9)
  5. TETRIS(10)
  6. utx.log
  7. Load a binary file (e.g. .WAV) into memory
  8. The Sound of MusicPDF
Debugging with gdb
SSD vs HDD: What's the Difference?
MIT's Oxygen Project
  1. [CFP29] Matrix Addition with Rational Entries
  2. [CFP30] Friend Function
  3. [CFP31] Matrix Determinant with Rational Entries
  4. [EX36] File Processing (Word Count)
  5. Subtitle of a Movie
Week 14 5/24
Chapter 10: The Standard Template Library

Quiz 13
  1. A Vector of Strings
  2. [EX38] Vector (1)
  3. [EX39] Vector (2)
  4. TETRIS (11)
  5. TETRIS (12)
  1. [CFP32] Sorting A Vector of Rational Numbers in Ascending Order
  2. [CFP33] Sorting a Vector of Rational Numbers in Descending Order
  3. Matrix
Week 15
5/31 Midterm Exam (2)

Students Should be Co-Laborers, Not Customers
Week 16 6/7
Chapter 12: Windows Programming with the Microsoft Foundation Classes
Chapter 14: Drawing in a Window
Quiz 14
  1. [EX] Lines and Rectangles
  2. [EX] Circles
  3. [HW] Pentagon
  4. [HW] Brush
  5. [HW] National Flags
Tech world preps to honor 'Father of Computer Science' Alan Turing, as centenary nears
第六感驚人的潛 力 Pranav Mistryvideo
  1. [Moodle] Star
  2. [Moodle] Square Wave
  3. [Moodle] Sine Wave
  4. Circle intersection
  5. Chapter 15: Working with Menus and Toolbars
    Display BITMAP filesPowerPoint
  6. How to display bitmap file
  7. Displaying Bitmaps in Visual C++ using Resources
  8. Code Guru - Displaying a Bitmap from a BMP File
  9. MSDN Bitmap Class
  10. [Moodle] TextOut()
  11. CreateFont()
  12. [Moodle] Polar Coordinate
Week 17 6/14
Chapter 16: Working with Dialogs and Controls
  • Edit Box
  • List Box
  • Enable a Button; Using Radio Buttons
Tutorial to MFC Controls 

Computer Science for Fun
Tesla, a Software Defined Car
NTT DoCoMo Vision (1)
NTT DoCoMo Vision (2) [wmv]
NTT DOCOMO Mobile Futurevideo

Week 18
6/21 Final Exam



  1. SoloLearn: Learn to Code for Free!
  2. Simple DirectMedia Layer (SDL)
  3. Tiled Map Editor
  4. Object-Oriented Graphics Rendering Engine (OGRE); OgreAL for audio.
  5. CodeFights
  6. ACM UVa Online Judge
  7. 線上解題系統 (NKNUSH)
  8. Advanced Programming (NSYSU)
  9. CPE 一星題
  10. Google Code University
  11. Codecademy
  12. Code for America
  13. Flowchart Drawing:
  14. Dia
  15. Dia for Windows
  16. An Introduction to Programming in Go
  17. Build Web Application with Golang


  1. Newton's Method
  2. What day is January 1?
    Ref: UVA 12019
  3. Calendar
  4. 190 - Circle Through Three Points
  5. Christmas Tree
  6. Prime Number
  7. Greatest Common Divisor
  8. Sorting
  9. Card Shuffling
  10. Dec2Float: 40 decimal = 0x42200000 IEEE Single Precision
  11. 蓊鬱錦簇科技二館 - 有蓊鬱的樹木圍繞著科技二館,使建築物融入大自然的美景中,更具生命力。
  12. 光鮮亮麗的山中城堡 - 雲群波濤洶湧、山脈層巒疊嶂及蓊鬱樹木圍繞,暨南大學校園無疑是美麗的歐式莊園。
  13. TypingTest (雙手聯彈)
  14. 小學乘法
  15. Sokoban
  16. Tetris
  17. [SourceForge] Mega Mario


  1. Pigeons with tiny backpacks test the air in London, and share tweeting
  2. Intel Labs Creating Robots of the Future
  3. 10 Ways Not to Be a Jerk Online
  4. 15 Windows Utilities You Can't Live Without
  5. IBM at 100: From typewriters to the cloud
  6. Future of the car (智慧汽車, 51 min) 447.18 F996