05-ops - char short int long long long unsigned float...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CPE 357 - Systems Programming Fall 2009, Day 5 Basic Operations Last Modified: Wed Sep 30 10:07:12 PDT 2009 Strings Show char foo[] = "abc"; strlen = 3 sizeof = 4 Show char foo[8] = "abc"; strlen = 3 sizeof = 8 How different from char *foo = "abc"; // read only foo[2] == 'c' foo[3] == '\0' Constants: READ ONLY \0 \n \t all we will usually fool with \a alert \b backspace \f formfeed \r cr \t tab \v vertical tab \\ backslash \? question mark \' \" \0 \00 \000 \xnn declaration declaration (establishes type) definition (declaration + reserve storage) initialization (all three) int a; //both int b = 1; Initialization Auto variables are likely to be junk. Uninitialized global variables are also likely to be junk. Even if not, don't depend on it, because it's an invisible action. Valgrind Types
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: char short int long long long unsigned float double long double * (4 bytes?) void * enum typedef Casts and conversions coercion in expressions assignment typecast Truncation int division assignment Autoincrement and autodecrement ++--order of operations dangers: a[i] = i++; b = c*i** + d*i++; % is underused. Think of it for "clock" arithmetic on cyclic things: tab stops, clocks, dates, making change Trinary op ? : Comma op , On strings: no language builtins, but common functions strlen, strcpy, strcat, strstr, strchr, etc Lab: f08: re-implement strcmp w09: re-implement strstr note: strncat and strncpy are not candidates because the Linux man page already has the code. vim: set sts=2 sw=2 ai et :...
View Full Document

Page1 / 2

05-ops - char short int long long long unsigned float...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online