Question: In PUTTY , The main goal for this program is to read an input file (specifically txt) with lines of characters representing the cases of
In PUTTY, The main goal for this program is to read an input file (specifically txt) with lines of characters representing the cases of binary string from 0-9, A-F and writing an output file txt containing the converted strings.
The following code (written in putty) is an early draft and can be edit to your liking:
int main()
{
char ch;
int i;
for (i=0;i<256;i++){
scanf(" %ch", &ch); // Just for testing; character to string through user input
switch (ch) {
case '0': printf("----");
break;
case '1': printf("---#");
break;
case '2': printf("--#-");
break;
case '3': printf("--##");
break;
case '4': printf("-#--");
break;
case '5': printf("-#-#");
break;
case '6': printf("-##-");
break;
case '7': printf("-###");
break;
case '8': printf("#---");
break;
case '9': printf("#--");
break;
case 'A': printf("#-#-");
break;
case 'a': printf("#-#-");
break;
case 'B': printf("#-##");
break;
case 'b': printf("#-##");
break;
case 'C': printf("##--");
break;
case 'c': printf("##--");
break;
case 'D': printf("##-#");
break;
case 'd': printf("##-#");
break;
case 'E': printf("###-");
break;
case 'e': printf("###-");
break;
case 'F': printf("####");
break;
case 'f': printf("####");
break;
default: printf("invalid operator");
break;
}
}
}
I need assistance into how to convert the following code into asking the user to write an EXISTING input file like "test.txt" containing characters and then write the OUTPUT file containing the converted characters above in PUTTY.
example: a text file "test.txt" contains: 67FB, we then execute the program telling us to input a text file containing characters, then it will ask us to NAME our output file. After completition, if we read the output file it should give us: "-##--########-##"
Please leave comments and steps as to why if you can, and thank you.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
