My programming partner and I have been working on a cool project dealing with binary/hex and it is working great. Everything is just about done and the mathematical side is finished moving into the second phase of user input we have run into some issues. Our ultimate goal is to open files read there contents and then convert to binary. Well the File IO is easy enough but we have run into a sort of standstill, this occurs in the conversion. At this point in the project Will and I have is testing with stdin, assuming we get that to work we will append the code for the File IO. Will and I have developed notes for the conversion:
Now I am sure some of you have already noticed the huge errors, I hope you will be able to solve my problem.Code:int main() { int k[SIZE]; char ch[SIZE]; fscanf(stdin,"%s",ch); for(i=0;i<SIZE;i++){ if(isalpha(char[i]) { k[i] = (int) (ch - 'A')+65 } else if(isalnum(charin[i])) { k[i] = atoi(charin); } /*This is just notes from code, if there is syntax errors it does not reflect the true code. I am unable to access the source at the moment*/
Error 1: Am I using the right Input function
Error 2: When a char string (1 byte element) holds an int greater then 255 it spaces it between many elements and / or it sets it to values 48-57 from ANSI
Values chart
Error 3: If the information is placed between elements or is converted to ANSI form then ATOI will ether not work correctly or will convert the number from the ANSI value
A few questions:
Should I use an int array? This will solve some issues with holding but other issues will be presented.
Is my conversion code k = (int)(ch-'A')+65 going to function correctly.
Thanks for your time!