Encrypting user input text files in c

Hi, I am very new to c and i am having some trouble with an assignment. I have to write a program that encrypts a file that was chosen by the user. I managed to write a program that asks for a file and prints it but i don't know how to ask for a key shift and actually encrypt the file. Here's what i have so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>

int main(void) {
FILE *file_in;
char filename[20];
char ch;
// file_in is the name given to the stream. filename will be the file that the user chooses. ch is the characters in the file.


printf("What file do you want to open?: ");
gets(filename);
	file_in=fopen(filename, "r");
	//ask the user to enter the name of a file

if(file_in==NULL)
printf("Error! File did not open.\n");
	//print message if the file can not be found

while((ch=fgetc(file_in)) != EOF) 
putchar(ch);
	//prints the results on the screen and shows the end of the file
fclose(file_in);
	//closes stream
}
Topic archived. No new replies allowed.