file generator...(beginning) Friday, 26-Feb-99 19:30:49 i'm stuck on how to translate the ROL's that produce the valid checksum...any suggestions? this will open caveman.dat, prompt for a username and put the number of bytes in username and username in the file, including the terminating '$'....as far as I've gotten so far... #include #include #include #include #include main() { FILE *fp; size_t length; long offset; int len; char buf[80]; char *x="$"; int i; if ( (fp = fopen("caveman.dat", "wb") )==NULL) { fprintf(stderr,"error opening file"); exit(1); } puts("enter your name: "); gets(buf); length=strlen(buf); len=length+1; fwrite(&len,sizeof(int),1,fp); fseek(fp, 2, 0); fwrite(buf, sizeof(length),length, fp); fseek(fp,len+1,0); fwrite(x,sizeof(char),1,fp); if ( (fp = fopen("test.txt", "rb") )==NULL) { fprintf(stderr,"error opening file"); exit(1); } fread(buf, sizeof(length),length, fp); printf("length of username is: %d",length); return 0; } snakebyte__ |
snakebyte's thread (snakebyte__@hotmail.com) (20-Feb-99 09:08:43) |