Added comments to explain certain code behaviors in ex1_10.c so that they can be read and referred to later more easily. Future code should be properly annotated on initial commit.

This commit is contained in:
Reina Harrington-Affine 2025-08-14 17:42:15 +00:00
parent 1ac53c22b2
commit d3262419a8

View file

@ -1,13 +1,13 @@
#include <stdio.h>
int main(){
int a = 0;
int a = 0; /*Initializing a as zero; this doesn't matter because getchar is called at the top of the loop */
while (a != EOF){
a = getchar();
if (a == '\b' || a == '\t' || a == '\\'){
if (a == '\b' || a == '\t' || a == '\\'){ /*Test whether the currently selected character is a tab, backspace, or backslash */
if (a == '\b'){
printf("\\b");
continue;
@ -15,7 +15,7 @@ int a = 0;
if (a == '\t'){
printf("\\t");
continue;
} else {
} else { /*There are only three possible cases here, and by the time we get here, we've tested two, hence an else statement is more efficient than doing another entire if statement*/
printf("\\\\");
continue;
}