C C Cheat Sheet Page 2

ADVERTISEMENT

printf formats:
%d: integer
%f: float or double
%s: string (char array)
%c: char (single character)
scanf formats:
%d: integer
%f: float
%lf: double (first character is L, not one!)
%s: string (char array)
%c: char (single character)
string methods:
/* to use these methods, you
must include <string.h> */
strcpy(char dest[], char src[])
copies src into dest
int strlen(char s[])
returns length of s
int strcmp(char s1[], char s2[])
returns negative if s1 < s2,
0 if s1 == s2
positive if s1 > s2
strcat(char dest[], char src[])
adds src to the end of dest
abstract classes and methods:
virtual void sound(char s[]) = 0;
// Reminder: no "abstract" keyword.
// Class headers do not indicate
// whether the class is abstract or
// not.
A class is abstract if it
// contains any abstract methods.

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 2