|
||
|
Lesson 1
C++ Course introduction
| ||
|
Welcome to Introduction to C++, the first course in the C++ for C Programmers series.
This course teaches you the basic differences between C++ and C and gets you started writing C++ programs. After completing this course, you'll be able to write C++ programs that:
#include <iostream> #include <cstring> using namespace std; void reverse(char *str, int count = 0); int main() { char *s1 = "This is a test."; char *s2 = "I like C++."; reverse(s1); // reverse entire string reverse(s2, 7); // reverse 1st 7 chars cout << s1 << '\n'; cout << s2 << '\n'; return 0; } void reverse(char *str, int count) { int i, j; char temp; if(!count) count = strlen(str)-1; for(i = 0, j=count; i < j; i++, j--) { temp = str[ i ]; str[ i ] = str[j]; str[j] = temp; } } |
||
|
|
||