Processing delimiter characters in C? Write a C program that will implement the basic operations of table processors.
The input will be text data read from a .txt file, operations will be defined using terminal arguments, and the output will be in a .txt file as well.
Program should be run the following way:
./main [-d delimiter] [name of the function for the table] &lt;in.txt &gt;out.txt

Where the -d argument determines which symbols can be interpreted as separators of single cells, by default the delimiter is a space character.
Multiple cases of the same sign in the delimiter are ignored.
The first sign in the delimiter character will be used as the separator of output values.
name of the function is the identifier of the function that will be called to perform certain tasks on the table. &lt;in.txt redirects reading from stdin to reading from in.txt, &gt;out.txt redirects outputting to stdout to outputting to out.txt.
Here's what I wrote:
#include &lt;stdio.h&gt; 
#include &lt;string.h&gt;

int main(int argc, char* argv[]) 
{   
    if((argc &gt; 2) &amp;&amp; (strcmp(argv[1], &quot;-d&quot;) == 0)) {
        char delim = *argv[2];  

        for (int i; (i = getchar()) != EOF; ) {
            if(i == '\n')
                putchar(i);


            if(!((i &gt;= '0' &amp;&amp; i &lt;= '9') || (i &gt;= 'a' &amp;&amp; i &lt;= 'z') || (i &gt;= 'A' &amp;&amp; i &lt;= 'Z')) ){                          
                putchar(delim);
                continue;
            }
            putchar(i);
        }

    }


    else if((argc == 2) &amp;&amp; strcmp(argv[1], &quot;-d&quot;) == 0) {
        char delim = ' ';

        for (int i; (i = getchar()) != EOF; ) {
            if(i == '\n')
                putchar(i);

            if(!((i &gt;= '0' &amp;&amp; i &lt;= '9') || (i &gt;= 'a' &amp;&amp; i &lt;= 'z') || (i &gt;= 'A' &amp;&amp; i &lt;= 'Z')) ){                          
                putchar(delim);
                continue;
            }
            putchar(i);
        }

    }


    return 0;
}

The code works and does what it's supposed to, but I am not sure about the effectivity of the implementation. The requirements are: input table can't be an empty file, maximum length of a row (both input &amp; output) is 10KiB, otherwise an error message should be shown. Using global variables isn't allowed, preprocessor macro #define is. Functions for working with files and dynamic memory allocation aren't allowed as well.
What are the ways to change my code?
It would be helpful for you to break up the code into functions, that will simplify each task.
Process the command line arguments first, then once you have the delimiter process the text files.

Declare the variable delim above any logic and initialize it to the default value
Process the command line to get the actual delimiter.
Process the input file.

This should shorten the code because you only need one loop to process the input file rather than 2.