Hello People! I hope everything's well...
Im a noob coder and I have the next question,
Here's my code, it copies character by character to another file.
Code:#include <stdio.h>int main (int argc, char *argv[]) { char caracter; char encrypt; char *archivaldo[20]; int cont; FILE *fp; FILE *fp2; if((fp=fopen(argv[1], "r"))==NULL) { printf("no se puede abrir"); } else { printf("si se pudo abrir"); fp2=fopen(argv[2], "w"); } while((caracter=getc(fp))!=EOF) { ////I want to take the caracter's ASCII value and save it to another variable, how can I do that?//// putc(caracter, fp2); } fclose(fp); fclose(fp2); } }
How In earth can I take the ASCII value of the 'caracter' variable and save it on another variable, let me remind you that the 'caracter' is always changing, you never know which letter its going to get.
If you need any more info, Im glad to give it.
Thank you for helping me out & taking the time to read.
****Btw(on a further note) I want to print on the second file as backwards, for example you read "Hello" I want it to be printed on another file as "olleH" I know you have to use LIFO structures, I know this may not be the place but can someone explain how to use this kind of structure?
///////////EDITTTTT////////
Ok, So, let me explain myself.
*Im reading the file character by character because I want to encrypt it using the ASCII values.
for example I've read a character 'R' which I believe is 82
I want ascii_variable=82///Its not going to be 'R' always, depends on the file.
How can I save the ascii value on to the variable ascii_variable...how is this possible?
//////////More EDITTTT////////////////////////////
Also, I want to take that ascii value and find the character that it is.
For example
ascii_variable=82
character_variable = ascii_variable interpretation (in this case 'R')
How In earth can I do this!!!!