Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This program is to convert ascii characters that are in a seperate input file in

ID: 3542405 • Letter: T

Question

This program is to convert ascii characters that are in a seperate input file into regular character with some parameters. The problem is when I use this program all that happens is the inputed number is repeated.

#include <stdio.h>

#define newline 72


int main()

{

    int iochar, i = 0;

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

        putchar(iochar);

        if (iochar <= 31 && iochar != 10) {

            iochar += 64;

            printf("^");

            i++;

            if (i > newline) {

                printf(" ");

                i=0;

            }

            printf("%c",iochar);

            if (i > newline) {

                printf(" ");

                i=0;

            }

        }

        else if (iochar==127) {

            printf("^");

            i++;

            if (i > newline) {

            printf(" ");

            i=0;

            }

            printf("?");

            i++;

            if (i > newline) {

            printf(" ");

            i=0;

            }

        }

        else if (iochar==' ') {

            printf("$ ");

            i++;

            if (i > newline) {

            printf(" ");

            i=0;

            }

        }

        else if (iochar>127 || iochar==NULL)

            printf("");

        else {

                printf("%c",iochar);

                i++;

                if (i > newline) {

                        printf(" ");

                        i=0;

                        }

        }

    }

    return 0;

}

Explanation / Answer

use char iochar and it will work fine

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote