Question: Can anyone help me identify what this code does and explain to me step by step what's going on? This is done in C language.
Can anyone help me identify what this code does and
explain to me step by step what's going on?
This is done in C language.
Here is the code.
void mapCharactersUsingFile (char * fileName , char * input , char * output) { FILE* fp = fopen(fileName, "r"); if(!fp) { printf("Q4: input.txt not opened"); return; } int count = 0; char a, b, c; char arr[100]; while(!feof(fp)) { fscanf(fp, "%c%c%c ", &a, &c, &b); arr[count] = a; arr[count + 1] = b; count += 2; } fclose(fp); int i = 0; for(; i < strlen(input); ++i) { int j = 0; int replace = 0; for(; j < 2 * count; j+=2) { if(arr[j] == input[i]) { output[i] = arr[j + 1]; replace = 1; } } if(!replace) output[i] = input[i]; } output[i] = '\0'; } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
