Re: Urgent HELP! required for Caesar Cipher PLEASE

From: Kevin Goodsell (usenet1.spamfree.fusion_at_neverbox.com)
Date: 12/14/03


Date: Sun, 14 Dec 2003 19:33:40 GMT

Carl Harris wrote:

<snip>

>
>
> void main()

int main(void)

main returns int. void is not and never has been an acceptable return
type for main.

>
> {
> FILE *Key;
> char c;
> char infile[100];
>
> printf("\n Input infile name:");
> gets(infile);

When posting code here, please use sane indenting, and don't use tabs.
They come out ugly if they work at all (Usenet protocols allow tabs to
be stripped from the beginning of a line, I believe). If you want people
to help with your code, the first step is to make it readable.

Also, never use the function gets(). Or, if you do choose to continue
using it, don't post code here that uses it. Also, please don't apply
for a job writing any kind of mission-critical software, or medical
software, or any kind of software for which security and correctness are
important. Consult the FAQ for more information.

> printf("The Key is: \n");
> if ((Key=fopen(infile,"r"))== NULL)
> {
> printf("can't open infile");

printf("can't open infile\n");

You need to terminate all text streams with a newline if you want your
program to be portable.

> exit(0);
> }
>
> else {
> do {
> c = getc(Key); /* get one character from the file */

c is the wrong type if you want to use it this way. getc returns int,
and you need to use something at least as wide as int to store the
result if you hope to be able to distinguish EOF from a regular character.

>
>
> putchar(c); /* display it on the monitor */
>
>
> } while (c != EOF); /* repeat until EOF (end of file) */
>
>
> printf("\n");
> }
> fclose(Key);
>
>
> FILE *text;
> char d;
> char plaintextfile[100];

You cannot mix declarations and executable code unless you are using
C99, which is very unlikely (since very few implementations of it exist).

-Kevin

-- 
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.