Implemented suggestions from affine. Considerably simplified the program by removing initialization for 'a' prior to loop entry; 'a' is now declared as the initialization expression for the loop, performing a getchar at the same time and preventing a null byte from being printed as the first character (even though this was not visible to the user).
This commit is contained in:
parent
abc0ac1660
commit
635a8300a3
1 changed files with 1 additions and 2 deletions
|
|
@ -4,9 +4,8 @@
|
|||
* as opposed to a series of if statements*/
|
||||
|
||||
int main(){
|
||||
int a = 0; /*Initialized as 0 becasue getchar is called both on loop entry, and after every successful execution*/
|
||||
|
||||
for (a = 0; a != EOF; a = getchar()){
|
||||
for (int a = getchar(); a != EOF; a = getchar()){
|
||||
switch (a){
|
||||
case '\t':
|
||||
printf ("\\t");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue