home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19832 < prev    next >
Encoding:
Text File  |  1993-01-24  |  1.7 KB  |  48 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!well!andras
  3. From: andras@well.sf.ca.us (Andrew Raskin)
  4. Subject: Re: HELP with File I/O
  5. Message-ID: <C1DI47.JJt@well.sf.ca.us>
  6. Sender: news@well.sf.ca.us
  7. Organization: Whole Earth 'Lectronic Link
  8. Date: Sun, 24 Jan 1993 19:28:55 GMT
  9. Lines: 37
  10.  
  11.  
  12. arsen@mindvox.phantom.com (Arsen Pereymer) writes:
  13.  
  14. >  Hi everyone... I am having some trouble with file I/O... I am new to the
  15. >  field of file i/o... My problem is, is that I want to write to a file in
  16. >  binary mode and then read from the file in binary mode... Here is the
  17. >  source code of what I did so far :#include<stdio.h> #include<conio.h>
  18. >  #include<string.h> #include<malloc.h> #include<dos.h> main() char *line;
  19. >  FILE *in, *out, *read; int i=0;
  20. >          clrscr();
  21. >          in = fopen("c:\\autoexec.bat","r");
  22. >          out = fopen("\\autoexec.dat","wb");
  23. >          for(i = 0;i <= 1;i++) {
  24. >                  line = (char *) malloc(sizeof(line));
  25. >                  fscanf(in,"%s",line);
  26. >                  fprintf(out,"%s",&line);
  27. >                  free(line);  }
  28. >          fclose(in);
  29. >          fclose(out);  char *r;
  30. >          read = fopen("\\autoexec.dat","rb");
  31. >          fscanf(read,"%s",&r);
  32. >          printf("\nName : %s",r);
  33. >          fclose(read);
  34. >          getch();
  35. >          return 0;
  36. >
  37. >
  38. >          Oops.. it messed up... Well anyways it is readable... as you can
  39. >  see from the above I want to convert the autoexec.bat into a binary
  40. >  format... Now The conversion works good... it creates a binary file called
  41. >  "Autoexec.dat"... But I am having trouble with reading line by line from
  42. >  the binary file? Any suggestions? Thanks in advance....
  43. >
  44.  
  45. I too am interested in this!
  46.  
  47. thanks!
  48.