Lecture 14: October 25, 2019
Reading
:
C text
, §11
Due
: Homework #2, due October 25, 2019
Greetings and felicitations!
Arrays of strings
int main(int argc, char *argv[])
(same as
int main(int argc, char **argv)
)
Example programs:
echo.c
,
echo2.c
Files
Review files and file pointers — mention file descriptors as underlying mechanism
Standard I/O library (
stdio.h
)
Standard input, output, error (
stdin
,
stdout
,
stderr
)
Opening, closing files (
fopen
,
fclose
)
Reading, writing characters and lines
Reading text data as lines (
fgets
,
gets
— do not use this!)
Reading text data as characters (
fgetc
,
getc
,
getchar
,
ungetc
)
Writing text data as lines (
fputs
,
puts
— latter adds a trailing newline)
Writing text data as characters (
fputc
,
putc
,
putchar
)
Reading, writing text data with a fixed format
Reading in text data with a fixed format (
fscanf
,
scanf
)
Outputting text data with a fixed format (
fprintf
,
printf
)
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email:
[email protected]
ECS 36A, Programming and Problem Solving
Version of October 30, 2019 at 8:28PM
You can also obtain a PDF version of this.