program7_4 - printf("Where bill.dat is the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// program7_4.cpp : Defines the entry point for the console application. // #include "stdafx.h" // program 7.3 #include "stdio.h" #include "stdlib.h" #define FALSE 0 #define TRUE !FALSE char buffer[10]; FILE *fp; int i; int icode; char code; void main( int argc, char *argv[]) { if (argc < 3) { printf("format: code bill.dat 100 \n"); printf("Where bill.dat is the file to code and 100 is the code (1 to 126) \n"); return; } code = (char)atoi(argv[2]); if ( (code > 126) || (code < 1)) { printf("code is out of range\n"); printf("format: code bill.dat 100 \n");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf(&quot;Where bill.dat is the file to code and 100 is the code (1 to 126) \n&quot;); return; } fp = fopen(argv[1],&quot;r+&quot;); if (fp == NULL) printf(&quot;Error reading %s \n&quot;,argv[1]); else { fseek(fp,0,SEEK_SET); fread(buffer,sizeof(buffer),1,fp); for (i = 0; i &lt; sizeof(buffer) - 1; i++) buffer[i] = buffer[i] ^ code; fseek(fp,0,SEEK_SET); fwrite(buffer,sizeof(buffer),1,fp); printf(&quot;%s was modefied!\n&quot;,argv[1]); } fclose(fp); }...
View Full Document

This note was uploaded on 09/16/2011 for the course EGN 3210 taught by Professor Fernando during the Spring '05 term at University of Central Florida.

Page1 / 2

program7_4 - printf(&amp;amp;quot;Where bill.dat is the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online