i want to implement a caesae cypher program in C given input.txt to be cyphered.
for example. assume the file input.txt contains
'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG'
when i run $./cypher input.txt 3 on terminal
we get out put of
'WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ'
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(int argc,char *argv[])
{
static int a[26];
int i=0,j,m,key;
char mes[100],res[100];
char ch;
FILE *fp;
key=atoi(argv[2]);
fp=fopen(argv[1],"r");
i=0;
while ( 1 )
{
ch = fgetc ( fp ) ;
if ( ch == EOF )
break ;
mes[i]=ch;
i++;
}
//printf("%s",mes);
fclose(fp);
for(i=0;mes[i]!='\0';i++)
{
ch=mes[i];
if(ch>='a' &&
ch<='z')
{
ch=ch+key;
if(ch>'z')
{
ch=ch-'z'+'a'-1;
}
}
else if(ch>='A' &&
ch<='Z')
{
ch=ch+key;
if(ch>'Z')
{
ch=ch-'Z'+'A'-1;
}
}
res[i]=ch;
}
printf("\n%s\n",res);
return 0;
}
I want to implement a caesae cypher program in C given input.txt to be cyphered. for example. ass...
You're to write a C++ program that analyzes the contents of an external file called data.txt. (You can create this file yourself using nano, that produces a simple ASCII text file.) The program you write will open data.txt, look at its contents and determine the number of uppercase, lowercase, digit, punctuation and whitespace characters contained in the file so that the caller can report the results to stdout. Additionally, the function will return the total number of characters read to...