2008. 3. 16. 22:49
@GSMC/서용덕: DMD Programming
Steve Oualline
Practical C Programming
5. Arrays, Qualifiers, and Reading Numbers
An array is a set of consecutive memory locations used to store data. Each item in the array is called an element. The number of elements in an array is called the dimension of the array.
To reference an element of an array, you use a number called the index -- the number inside the square brackets.
Strings are sequences of characters. Strings are just character arrays with a few restrictions.
\0
strcpy(string1, string2)
Copy string
variable-length strings
strcat(string1, string2)
Concatenate strings
: to add a space
strlen(string)
Get string length
strcmp(string1, string2)
Compare two strings
fgets
Get string from stream
sizeof (name)
stdin
standard input stream
'\n'
newline
'\0'
end-of-line
Multidimensional Arrays
type variable[size1][size2];
printf
scanf
Read formatted data from stdin
fgets
sscanf
Read formatted data from string
: string scanf
Types of Integers
Types of Floats
Side Effects
A side effect is an operation that is performed in addition to the main operation executed by the statement.
Practical C Programming
5. Arrays, Qualifiers, and Reading Numbers
An array is a set of consecutive memory locations used to store data. Each item in the array is called an element. The number of elements in an array is called the dimension of the array.
To reference an element of an array, you use a number called the index -- the number inside the square brackets.
Strings are sequences of characters. Strings are just character arrays with a few restrictions.
\0
strcpy(string1, string2)
Copy string
variable-length strings
strcat(string1, string2)
Concatenate strings
: to add a space
strlen(string)
Get string length
strcmp(string1, string2)
Compare two strings
fgets
Get string from stream
fgets (name, sizeof (name), stdin);
cf. Chapter 14. File Input/Outputsizeof (name)
stdin
standard input stream
'\n'
newline
'\0'
end-of-line
Multidimensional Arrays
type variable[size1][size2];
printf
scanf
Read formatted data from stdin
fgets
sscanf
Read formatted data from string
: string scanf
C lets you give detailed information about how the hardware is to be used. - 75p
Types of Integers
%hd
signed short int
%d
signed int
%ld
signed long int
%hu
unsigned short int
%u
unsigned int
%lu
unsigned long int
signed short int
%d
signed int
%ld
signed long int
%hu
unsigned short int
%u
unsigned int
%lu
unsigned long int
Types of Floats
%f
float (printf only)
%lf
double (scanf only)
%Lf
long doubel (not available on all compilers)
float (printf only)
%lf
double (scanf only)
%Lf
long doubel (not available on all compilers)
Side Effects
A side effect is an operation that is performed in addition to the main operation executed by the statement.
'@GSMC > 서용덕: DMD Programming' 카테고리의 다른 글
[Steve Ouallline] 6. Decision and Control Statements (0) | 2008.03.25 |
---|---|
week 3 review (0) | 2008.03.22 |
hw2 (0) | 2008.03.15 |
week 2 review (0) | 2008.03.15 |
[Steve Oualline] 4. Basic Declarations and Expressions (0) | 2008.03.10 |