home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!well!andras
- From: andras@well.sf.ca.us (Andrew Raskin)
- Subject: Re: HELP with File I/O
- Message-ID: <C1DI47.JJt@well.sf.ca.us>
- Sender: news@well.sf.ca.us
- Organization: Whole Earth 'Lectronic Link
- Date: Sun, 24 Jan 1993 19:28:55 GMT
- Lines: 37
-
-
- arsen@mindvox.phantom.com (Arsen Pereymer) writes:
-
- > Hi everyone... I am having some trouble with file I/O... I am new to the
- > field of file i/o... My problem is, is that I want to write to a file in
- > binary mode and then read from the file in binary mode... Here is the
- > source code of what I did so far :#include<stdio.h> #include<conio.h>
- > #include<string.h> #include<malloc.h> #include<dos.h> main() char *line;
- > FILE *in, *out, *read; int i=0;
- > clrscr();
- > in = fopen("c:\\autoexec.bat","r");
- > out = fopen("\\autoexec.dat","wb");
- > for(i = 0;i <= 1;i++) {
- > line = (char *) malloc(sizeof(line));
- > fscanf(in,"%s",line);
- > fprintf(out,"%s",&line);
- > free(line); }
- > fclose(in);
- > fclose(out); char *r;
- > read = fopen("\\autoexec.dat","rb");
- > fscanf(read,"%s",&r);
- > printf("\nName : %s",r);
- > fclose(read);
- > getch();
- > return 0;
- >
- >
- > Oops.. it messed up... Well anyways it is readable... as you can
- > see from the above I want to convert the autoexec.bat into a binary
- > format... Now The conversion works good... it creates a binary file called
- > "Autoexec.dat"... But I am having trouble with reading line by line from
- > the binary file? Any suggestions? Thanks in advance....
- >
-
- I too am interested in this!
-
- thanks!
-