60 likes | 228 Views
C vs. C++. I/O Declaration Placement Strings Minor syntax differences ( ala enum ). C vs. C++ Standard I/O. I/O C uses printf and scanf C++ uses cin , cout. C vs. C++ Declaration Placement. Declaration Placement C++ allows a declaration to be placed anywhere
E N D
C vs. C++ • I/O • Declaration Placement • Strings • Minor syntax differences (alaenum)
C vs. C++ Standard I/O • I/O • C uses printf and scanf • C++ uses cin, cout
C vs. C++ Declaration Placement • Declaration Placement • C++ allows a declaration to be placed anywhere • C only allows declarations BEFORE any executable statements within a “block” • A block starts with a { and ends with a }
C vs. C++ Strings • Strings • C++ provides powerful string class, and thus MOST space required for strings not explicitly stated by programmer • C requires explicit declaration of space (either static or dynamic) for string space (as an array of char values) • C uses a library of string functions, including strcpy, strcat, strlen, strcmp, …
CSP Machine “Gotchas” • Note: This slide is an anachronism. It no longer applies as we don’t use the CSP machines anymore. I include it to show how good you have it now! • Declaration placement in C programs • Quoted Strings wrapped around lines, • Printf(“This will be a string that is wrapped around a single line. It is not allowable in C, BUT the csp machine gcc (very old) doesn’t seem to recognize that\n”);