Table of Contents
Intro to Programming Teaching Assistant --- week6
Agenda
switch cases, ternary operators.
Notes
-
printf before infinite loop does n’t seem to be executed
-
Solution
- The way printf() works is like this: it stores the value to be printed in a buffer or a reserve. It only displays it to the terminal(stdout) when either there is a /n (newline) in the printf() or if the program terminates. Since neither happens here, the output of the first printf (which is before the infinite loop) is not displayed. Read this.
-
$ \ $
-
tail -10 t.c > t.c returns an empty file
$ \ $
-
wc -l file returns filename, though wc -l < file doesn’t
-
Solution
In the second case, when stdin is set to file1, wc no longer knows its using file1 as input, it just works with stdin. To try this out, you can just type:
$ wc -l
This is allow you to enter text and when you hit ctrl D, you get the number of lines you entered (and without the file name).
-
$ \ $
-
Defining functions with variable arguments in c
- Read this
- $ \ $