1 / 5

C vs. C++

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

Download Presentation

C vs. C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C vs. C++ • I/O • Declaration Placement • Strings • Minor syntax differences (alaenum)

  2. C vs. C++ Standard I/O • I/O • C uses printf and scanf • C++ uses cin, cout

  3. 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 }

  4. 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, …

  5. 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”);

More Related