Swapping int with string using getchar() and putchar() I wrote code that replaces integers from 0 to 3 with strings. I was only allowed to use getchar() and putchar(). If the input is 1, the output will become "one".

#include &lt;stdio.h&gt;


int main()
{


int c;            

char* arr[4] = {"zero", "one", "two","three"};

int i;

  while ((c = getchar ()) != EOF) 
    {

        if(c==0+'0'){
        char* str = arr[0];
    for (i = 0; str[i] != '\0'; i++) {

    putchar(str[i]);

}
}


else if(c==1+'0'){
char* str = arr[1];
      for (i= 0; str[i] != '\0';i++) {

    putchar(str[i]);


}
}

else if(c==2+'0'){
char* str = arr[2];
      for (i = 0; str[i] != '\0'; i++) {
        putchar(str[i]);

}
}
else if(c==3+'0'){

    char* str = arr[3];
     for (i = 0; str[i] != '\0'; i++) {
    putchar(str[i]);

}   
}



        else
        putchar(c);

   }

return 0;


}


The code is pretty long. Is there a shorter way to write it?
Review
Vertical White Space
You have way too many blank lines.
Please remove 90% of them.
Formatting
This code is horribly formatted.
Code is designed for humans to read. Part of that is making sure it is easy to read.
DRY
There is one piece of code that is repeated several times.
for (i = 0; str[i] != '\0'; i++) {
    putchar(str[i]);
}

You can simplify your code by putting this into its own function. Then calling the function when you want to print out the string.
Easier to read
Your comparisons to check for a number is overly complex:
else if(c==2+'0'){

The c is a character so simply compare the user input to the expected character:
 else if (c == '2') {