How to shift array?

Task: Read, Eycrpt and Write ( Stuck in My C programming Project )

*Your program should now ask the user for the name of the output file and to enter the alphabetic offset key, apply the encryption and write the cipher text to the output file.

Note: I've managed to read input.txt file character by character & write the file onto output.txt but I don't know how can I encrypt the file in ceaser cipher. I need to do is shift the array between 1-25 spaces, as thats the alphabet before you do a full circle on your self.

The encryption needs to be a caeser cipher. Im a beginner and I'm really confused!

If you add something can you please explain what it is meant to be doing in the code. Thank you :)

_____________________________________________________________________________________________________________________________________________

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<conio.h>

void main()
{
FILE *file_in;
FILE *file_out;

char apple[200];
char fname[100];
char cipher[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

printf("please enter the file which you would like to open and encrypt:");
scanf( "%s", fname);

file_in = fopen(fname, "r");

int i=0;

while (!feof(file_in))
{
fscanf(file_in,"%c",&apple[i]);

i++;
}

apple[i] = 0x00;

printf("\n%s\n", apple);

printf("\nplease enter the file which you would like to write to and encrypt:");
scanf( "%s", fname);

file_out = fopen(fname, "w");


fprintf(file_out,"%s\n", apple);

file_out = fopen(fname, "r");

printf("\n%s\n", apple);

fclose(file_out);
fclose (file_in);

getch();
}


Last edited on
You have to copy arrays
Last edited on
How? can you show me an example please :)
Last edited on
Help! anyone?
Topic archived. No new replies allowed.