Lesson 1.1: Hello, world
Lesson 1.1: Hello, world
Lesson 1.1: Hello, world
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Lesson</strong> 1.5:<br />
Character input and output (1/3)<br />
Programming in C<br />
Prof. Dr. Eike Best<br />
Dr. Elke Wilkeit<br />
September 28, 2002<br />
1 #include <br />
2<br />
3 /* copy input to output; 1st version */<br />
4 main()<br />
5 {<br />
6 int c;<br />
7<br />
8 c = getchar();<br />
9 while (c != EOF) {<br />
10 putchar(c);<br />
11 c = getchar();<br />
12 }<br />
13 }<br />
1 #include <br />
2<br />
3 /* copy input to output; 2nd version */<br />
4 main()<br />
5 {<br />
6 int c;<br />
7<br />
8 while ((c =getchar()) != EOF)<br />
9 putchar(c);<br />
10 }<br />
Exercise 1-6. (EOF) Verify that the expression getchar() != EOF is 0 or 1.<br />
Exercise 1-7. (EOF again)<br />
Write a program to print the value of EOF.