[Instructions] [Search] [Current] [News] [Syllabus] [Glance] [Links] [Handouts] [Outlines] [Labs] [Assignments] [Exams] [Examples] [Project]
Back to C Basics. On to Headers and Formatted I/O.
Held Friday, February 4, 2000
Overview
Today, we consider types in C.
Notes
/usr/include. For example,
<stdio.h> is in
/usr/include/stdio.h
<netinet/in.h> is in
/usr/include/netinet/in.h
Contents
Summary
int: integers
float: floating-point values
double: floating-point values, with potentially
greater precision than floats
char: characters (which you can also treat as integers)
int16
for sixteen-bit integers) and hope that someone
will rename appropriately on each platform
typedef operation.
typedeftypename;
typedef int grade;
enum { val1, val2, ,..., valn }
enum { alpha, beta, gamma } stuff;
stuff whose
legal values are (more or less), alpha, beta,
and gamma.
typedef operation.
typedef enum { male, female, neuter } gender;
gender x = male;
int and numbers the values of that type from 0 to
whatever.
structs.
structs are a lot like classes except that they don't
have methods.
struct date {
int year;
int month;
int day;
}; /* struct date */
struct date.
struct date today; today.year = 2000; today.month = 2; today.day = 4;
typedefs.
structs called
unions. The primary difference is that all
the fields of a union share the same memory.
int grades[34];
int stuff[2];
int i;
for (i = 0; i < 10; i++)
printf("%d\n", stuff[i]);
type[] as the parameter.
toString(day) method that converts
an enumerated day to the corresponding string.
fromString(str) method that turns a string
in to the corresponding enumerated day of the week.
Thursday, 20 January 2000
Friday, 4 February 2000
Back to C Basics. On to Headers and Formatted I/O.
[Instructions] [Search] [Current] [News] [Syllabus] [Glance] [Links] [Handouts] [Outlines] [Labs] [Assignments] [Exams] [Examples] [Project]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS364/2000S/Outlines/outline.06.html
Source text last modified Fri Feb 4 13:54:04 2000.
This page generated on Fri Feb 4 13:52:39 2000 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu