Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   C/C++ Caesar Cipher on a .txt file? (http://www.go4expert.com/forums/c-cpp-caesar-cipher-txt-file-t7861/)

BillyBob 16Dec2007 01:59

C/C++ Caesar Cipher on a .txt file?
Hi, How would I go about using the Caesar Cipher technique on a .txt file? E.g. shifting each letter by 3?

Here is my code?


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

#define CNTRLZ 0x1A

char sourceFileName[] = "H:\\text.txt";
char commStreamName[] = "COM1";
FILE *commStream;
FILE *SouceFile;
char charToSend;
char ReadAccess[] = "r";
char WriteAccess[] = "w";
char errorMsg[] = "fail to open data file\n";
char fileopenflag[] = "r";
char EndOfFile[] = "EOF";

int main(void) {
FILE *fp;
FILE *dp;
int c;

if ((dp = fopen("COM1", "r")) == NULL) {
printf("fail to open COM port\n"); return 1;

if ((fp = fopen( sourceFileName, "w")) == NULL) {
printf("fail to open data file\n"); return 1;

while ((c = fgetc(fp )) != EOF) {
fputc( c, dp);


fputc('*', dp);

Any ideas where to start?

Salem 16Dec2007 05:38

Re: C/C++ Caesar Cipher on a .txt file?
Did you even pay any attention to your other thread, with the same code?

BillyBob 16Dec2007 05:56

Re: C/C++ Caesar Cipher on a .txt file?
You weren't no help as usual.

shabbir 16Dec2007 09:15

Re: C/C++ Caesar Cipher on a .txt file?
Duplicate of C Encryption?? Adding Encryption To Text File?. Thread closed.

If you did not understand on that thread try responding what you could not understand instead of starting fresh.

All times are GMT +5.5. The time now is 05:24.