forsaken_sorceress
2011-12-08 01:33:57 UTC
Any help would be appreciated. This is what I have so far.
#include
#include
#include
#include
#include
#define ELEMENT 500 // defines the elements in an array to 500
#define LENGTH 100 // defines the length in an array to 100
void loadfile(); // defining the prototype
void loadfile() // defining the program
{
FILE *filepointer;
int wordnum, is_end, poswithin, shiftletters; //initialising the variables as integers
char read_char; // initialising a variable called read_char
char filename[50]; // defining the name of file and limiting to 50 characters
char str[ELEMENT][LENGTH],messege[999]; // initialising the parameters and limits of the string
printf("Please type in the name of the file you want to have encrypted \n"); // promting the user to input the filename
scanf("%s", filename); // assigning the text inputed to variable filename
filepointer=fopen(filename,"r"); //search for file name inputted by user
poswithin=0; wordnum=0;
is_end=fscanf(filepointer,"%c",&read_char); //reading the found text file
while (is_end!=EOF) // while the file is at end
{
if (isupper(read_char) || islower(read_char))
{
printf("%c", read_char); //print out the document to screen
str[wordnum][poswithin]=read_char; poswithin++;
}
else
{
str[wordnum][poswithin]=(char)'\n';
poswithin=0; wordnum++;
printf(" ");
}
scanf("%c", &messege);
is_end=fscanf(filepointer,"%c",&read_char);
printf("\n\n\nPlease type in the alphabetical offset key. (1-25)\n");
fflush(stdin);
scanf("%d", &shiftletters);
for(int i=0;i
// checking for upper case
if((messege[i]>='A')&&
(messege[i]<='Z'))
messege[i]=((messege[i]-'A') + shiftletters) % 26 + 'A';
else
//checking for lower case
if((messege[i]>='a')&&
(messege[i]<='z'))
messege[i]=((messege[i]-'a') + shiftletters) % 26 + 'a';
}
printf("%d",messege);
}
fclose(filepointer);
}
void main()
{
loadfile();
}