Re: file generator...(final) Thursday, 04-Mar-99 03:32:44 #include < string.h> #include < stdio.h> #include < stdlib.h> #include < conio.h> FILE *fp; int length; char new[2]; char *new_ptr=new; char buf[80]; char *buf_ptr=buf; char end[]="$"; long a; int i; main() { puts("enter username: "); gets(buf); strcat(buf,end); length=strlen(buf); printf("username with trailing $ : %s\n",buf); printf("username is %d characters.\n",length); asm{ mov cx,length xor ax,ax mov si,buf_ptr } label: asm{ lodsb add ah,al rol ax,1 rol ax,1 rol ax,1 loop label mov new_ptr,ax } printf("checksum : %x\n",new_ptr); printf("creating caveman.dat "); if ( (fp = fopen("caveman.dat", "wb") )==NULL) { fprintf(stderr,"error opening file"); exit(1); } fwrite(&length,sizeof(int),1,fp); fwrite(buf_ptr, sizeof(char),length, fp); fwrite(&new_ptr,sizeof(new_ptr),1,fp); fclose(fp); return 0; } oops...forget to paste in the code... |
snakebyte's thread (snakebyte__@hotmail.com) (20-Feb-99 09:08:43) |