{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

program7_4 - printf"Where bill.dat is the file to code...

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 Document Right 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("Where bill.dat is the file to code and 100 is the code (1 to 126) \n"); return; } fp = fopen(argv[1],"r+"); if (fp == NULL) printf("Error reading %s \n",argv[1]); else { fseek(fp,0,SEEK_SET); fread(buffer,sizeof(buffer),1,fp); for (i = 0; i < sizeof(buffer) - 1; i++) buffer[i] = buffer[i] ^ code; fseek(fp,0,SEEK_SET); fwrite(buffer,sizeof(buffer),1,fp); printf("%s was modefied!\n",argv[1]); } fclose(fp); }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

program7_4 - printf"Where bill.dat is the file to code...

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

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