hey guys, i posted a encoding/decoding thread a litle while ago. i've gotten some what far on it, but now i just don't know how to write the most important part. the actual decoding. i need to essentially cut the secret message numbers (22384) and only use the first two numbers to determine the character (22). what statements can i use to 'cut' it? if there are any suggestions on what to use in relation to my code would be fantastic. thanks for your help!
#include <stdio.h>
FILE *csis *fp;
void getCode(char code[53]);
int getMessage(int msg[]);
void sortMessage(int msg[], int msgSize);
void decodeMessage(char code[53], int msg[], int msgSize);
void main(void){
int i; char code;
//Calls methods
getCode(char code[53]);
getMessage(int msg[]);
sortMessage(int msg[], int msgSize);
decodeMessage(char code[53], int msg[], int msgSize);
return 0;
//....... calls the four methods
}//end main
void getCode(char code[53]) {
fopen_s(&fp, "codefile.txt", "r");
int i; char code;
while (!feof(fp)) //loops file till end
fscanf_s(fp, "%c\n", &code); //places file contents in i
for (a[i]= code; i++); //adds i to it self to continue with contents
}
int getMessage(int msg[]) {
fopen_s(&csis, "msgfile.txt", "r");
int j; char msg;
while (!feof(csis))
fscanf_s(csis, "%c\n", &msg);
for (msg[j]= msg; j++);
}//end getMessage
void sortMessage(int msg[], int msgSize) {
int i, j, temp;
for (i = 1; i < msgSize; i++) {
temp = msg[i];
j = i - 1;
while (j >= 0 && temp < msg[j];{
msg[j+1] = msg [j]
j = j + 1;
}
msg[j+i] = temp;
}//end sortMessage
void decodeMessage(char code[53], int msg[], int msgSize);
int i, j;