Thread: Re: [Dev-C++] how to use strings
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Michael C. <jd...@ho...> - 2001-09-04 07:11:00
|
Hi,
Yes this is how I would have done this in the past, it's just that the
person wanted to use fprintf().
Also, I would have used stat() to obtain the size of the file unless (which
is why you have shown this) the file is too big and you just wanted to read
it in chunks.
Generally, (as you know) we know the size of the structs we read in so we
would probably allocate memory for a number of structs and read that in at
one time - whatever is more efficient for our program to do.
Michael
>From: Johannes Pretorius <joh...@pr...>
>To: "Michael C" <jd...@ho...>
>CC: dev...@li...
>Subject: Re: [Dev-C++] how to use strings
>Date: Tue, 04 Sep 2001 07:38:15 +0200
>
>Okay I dont reaaly know what You want to do. Considering you want to read
>in a structure I will say use fread !!! else try something like
>this if you want a block of data
>
>//SNIP
>
>#include <stdio.h>
>#include <fcntl.h>
>#include <alloc.h> /* alloc.h for Borland compilers,
> malloc.h for Microsoft compilers */
>
>#define BUFFER_SIZE 0x8000 /* 32Kb data buffer */
>
>main(int argc, char *argv[]) {
> int Handle;
> unsigned int Checksum;
> unsigned char *WorkingBuffer;
> int WorkingLength;
>
> if ( argc != 2 ) {
> printf("usage: checksum filename\n");
> exit(1);
> }
>
> if ( (Handle = open(argv[1], O_RDONLY | O_BINARY)) == -1 ) {
> printf("Can't open file: %s\n", argv[1]);
> exit(1);
> }
>
> /* Get memory in which to buffer the data */
> if ( (WorkingBuffer = (unsigned char *)malloc(BUFFER_SIZE)) == NULL ) {
> printf("Can't get enough memory\n");
> exit(1);
> }
>
> /* Initialize the checksum accumulator */
> Checksum = 0;
>
> /* Process the file in 32Kb chunks */
> do {
> if ( (WorkingLength = read(Handle, WorkingBuffer,
> BUFFER_SIZE)) == -1 ) {
> printf("Error reading file %s\n", argv[1]);
> exit(1);
> }
> /* Checksum this chunk if there's anything in it */
> if ( WorkingLength ) {
> //Beneath part is in assembler file. So I commented it out
> //ChecksumChunk(WorkingBuffer, WorkingLength, &Checksum);
> }
> } while ( WorkingLength );
>
> /* Report the result */
> printf("The checksum is: %u\n", Checksum);
>
> exit(0);
>}
>
>//END SNIP
>
>NOTE : The above code will always have a checksum of 0 as it is not calling
>the assembler function that is in a different file.
>else a more simple straight forward approach will be
>
>//SNIP
>/*
> * Program to calculate the 16-bit checksum of the stream of bytes
> * from the specified file. Obtains the bytes one at a time via
> * getc(), allowing C to perform data buffering.
> */
>#include <stdio.h>
>
>main(int argc, char *argv[]) {
> FILE *CheckFile;
> int Byte;
> unsigned int Checksum;
>
> if ( argc != 2 ) {
> printf("usage: checksum filename\n");
> exit(1);
> }
>
> if ( (CheckFile = fopen(argv[1], "rb")) == NULL ) {
> printf("Can't open file: %s\n", argv[1]);
> exit(1);
> }
>
> /* Initialize the checksum accumulator */
> Checksum = 0;
>
> /* Add each byte in turn into the checksum accumulator */
> while ( (Byte = getc(CheckFile)) != EOF ) {
> Checksum += (unsigned int) Byte;
> }
>
> /* Report the result */
> printf("The checksum is: %u\n", Checksum);
>
> exit(0);
>}
>
>//END SNIP
>
>Now this is basic stuff that I can think of right now. Futher more if you
>can give more information on what you want to achieve maybe we can help
>
>
>hope this helps
>Johannes
>
>
>
>At 21:34 03/09/2001 +0100, you wrote:
>>Hi,
>>
>>I havn't programmed in C for a couple of years now, I've been
>>concentrating
>>on C++.
>>I have forgotten a few things so I'm watching this group for input, and
>>I've
>>been impressed by what I have seen.
>>
>>I had a look at your code and spotted a few things:
>>
>>1) For fopen() use "w+" as you need to read it as well.
>>2) Use ' fseek (fhandle, 0L, SEEK_SET);' to reposition the file to the
>>beginning for reading.
>>3) Dereference fhandle (*fhandle) in the fprintf() statement and this will
>>read in the string.
>>3) fprintf() and fscanf() do not move the file position and I can't
>>remember
>>how to do this. So another call to fprintf() will not read the stringified
>>number on the next line. I thought I could use:
>> 'fseek (fhandle, len, SEEK_CUR);' where len is the returned value
>>from a successful call to fprintf()
>> However, this doesn't work. Instead I prefer to use:
>>
>> int c;
>> while ((c = fgetc (fhandle)) != EOF)
>> {
>> fputc (c, stdout);
>> }
>>
>>Any comments?
>>
>>Hope this helps.
>>
>>Michael
>>
>>----- Original Message -----
>>From: Johannes Pretorius <joh...@pr...>
>>To: <jsc...@gm...>
>>Cc: <dev...@li...>
>>Sent: Monday, September 03, 2001 2:07 PM
>>Subject: Re: [Dev-C++] how to use strings
>>
>>
>> > this here is a simple example that will make more sense. For
>>considering
>> > that you are trying to mix
>> > your WINAPI functions and write to the handle of the file allocators. I
>>do
>> > not think that it is possible in
>> > the compiler version. Maybe with a Microsft compiler.
>> >
>> > else this is a VERY simple way to do it that works. I hope this help.,
>> > Please mail if I misunderstand you.
>> >
>> > file://====== SNIP =========
>> >
>> > #include <iostream.h>
>> > #include <stdio.h>
>> > #include <stdlib.h>
>> >
>> >
>> >
>> > struct test{
>> > char data [200];
>> > }testdata;
>> >
>> > void main(void){
>> > char outstring[200];
>> > FILE *fhandle;
>> > int actualnumber;
>> >
>> > file://open in write mode (override if exist);
>> > fhandle = fopen("c:\\medcelldata.txt","w");
>> > /*CreateFile("c:/medcelldata.txt",
>> > GENERIC_READ | GENERIC_WRITE,
>> > 0,
>> > NULL,
>> > OPEN_ALWAYS,
>> > FILE_ATTRIBUTE_NORMAL,
>> > NULL
>> > );
>> > */
>> >
>> > if(fhandle == NULL)
>> > {
>> > printf("\nNO File present");
>> > }
>> >
>> > file://copy test to structuer
>> > strcpy(testdata.data,"Hallo World\n");
>> >
>> > actualnumber = 1000;
>> >
>> > file://write using fwrite (BETTER for Structures)
>> > fwrite(&testdata, sizeof(testdata), 1, fhandle);
>> >
>> > file://convert integer
>> > itoa(actualnumber, outstring, 10);
>> >
>> > file://write with fprintf to file
>> > fprintf(fhandle,"OutString : %s",outstring);
>> >
>> > file://clsoe file
>> > fclose(fhandle);
>> > }
>> >
>> >
>> >
>> >
>> > file://========= END SNIP =========
>> >
>> > Hope it helps
>> > Johannes
>> >
>> >
>> >
>> > At 14:03 03/09/2001 +0200, you wrote:
>> > >On 3 Sep 2001, at 11:57, Johannes Pretorius wrote:
>> > >
>> > > > Johannes Pretorius <joh...@pr...>
>> > >
>> > >
>> > >Here it is ! i allready change something to make it run - but in the
>> > >written file there only occurs 1- or two figures !
>> > >
>> > >How can i use the fprintf - function to access the file ????
>> > >
>> > >
>> > >
>> > >#include <iostream.h>
>> > >#include <stdio.h>
>> > >#include <stdlib.h>
>> > >#include <windows.h>
>> > >
>> > >// vars
>> > >
>> > >HANDLE hcom; // file handler
>> > >HANDLE hfile;
>> > >DWORD dwWritten;
>> > >
>> > >int value[8];
>> > >int numofdata[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} ;
>> > >
>> > >BYTE noise; // for testing only
>> > >BYTE activeitem; // no of active row
>> > >
>> > >BYTE in_buffer[35]; // input buffer = 8
>>needed
>> > >BYTE out_buffer[35]; // output buffer
>> > >
>> > >int writepoint;
>> > >int readpoint;
>> > >int writepointin; // write pos inbuffer
>> > >int readpointin; // read pos inbuffer
>> > >int goodvalue;
>> > >int tempvalue;
>> > >int actualnumber;
>> > >
>> > >BYTE input;
>> > >BYTE count;
>> > >int globalschleife;
>> > >LPTSTR lpMessage;
>> > >
>> > >int progmode; // bin or asc
>> > >
>> > >
>> > >....
>> > >
>> > > hfile = CreateFile("E:/medcelldata.txt",
>> > > GENERIC_READ | GENERIC_WRITE,
>> > > 0,
>> > > NULL,
>> > > OPEN_ALWAYS,
>> > > FILE_ATTRIBUTE_NORMAL,
>> > > NULL
>> > > );
>> > >
>> > > if(hfile == INVALID_HANDLE_VALUE)
>> > > {
>> > > printf("\nNO File present");
>> > > }
>> > >
>> > > pstr = "MedCellCom 1.2\n\n ";
>> > > WriteFile(hfile, pstr, 16, &dwWritten, NULL);
>> > >
>> > >
>> > > pstr = "Prozess - Protokoll vom : \n ";
>> > >
>> > > WriteFile(hfile, pstr, 27, &dwWritten, NULL);
>> > >
>> > >
>> > > itoa(actualnumber, outstring, 10);
>> > >
>> > > WriteFile(hfile, outstring, 10, &dwWritten,
>>NULL);
>> > >
>> > > WriteFile(hfile, "456", 3, &dwWritten, NULL);
>> > >
>> > > printf("%d\t", dwWritten);
>> > > printf("%s\n", outstring);
>> > >
>> > >
>> > >
>> > >The output shows only
>> > >
>> > > MedCellCom 1.2
>> > >
>> > > Prozess - Protokoll vom :
>> > >2
>> > >
>> > >Where "2" ist the actualnumber
>> > >
>> > >I do not see the 456 test string allthoug the screen
>> > >shows the correct outstring and 3 chars written !
>> > >
>> > >It is a big loop, where many lines are written and
>> > >shown on the screeen it works and the prog terminates.
>> > >
>> > >When writing only dummy strings like explicit
>> > >"iugnuztf" it works and show 200 lines with exactly
>> > >this text !
>> > >
>> > >????
>> >
>> >
>> > _______________________________________________
>> > Dev-cpp-users mailing list
>> > Dev...@li...
>> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>> >
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|
|
From: Michael C. <jd...@ho...> - 2001-09-04 07:48:59
|
Hi,
Did you get the fprintf to work because I am still having trouble.
I have also tried it at work on a HPUX 10.20 aCC compiler but neither
version works for reading from a file.
fprintf (stdout, "%s", fhandle);
fprintf (stdout, "%s", *fhandle);
Note, the second version works on the Dev C++ compiler but reads the first
line only.
And yes, I agree there are many ways to move the file pointer and that
seeking to the end of a string is bad strategy. I was just trying to get the
thing to read from a file using fprintf().
Michael
>From: "Ioannis Vranos" <no...@ya...>
>To: "Dev-C++" <dev...@li...>
>Subject: RE: [Dev-C++] how to use strings
>Date: Tue, 4 Sep 2001 02:13:53 +0200
>
> > -----Original Message-----
> > From: dev...@li...
> > [mailto:dev...@li...] On Behalf
> > Of Michael C
> > Sent: Monday, September 03, 2001 10:37 PM
> > To: dev...@li...
> > Subject: Re: [Dev-C++] how to use strings
> > 3) fprintf() and fscanf() do not move the file position and I
> > can't remember how to do this. So another call to fprintf()
>
>Of course they do. There are thousands of many ways to move the file
>position, fseek(), fread(), ....
>
> > will not read the stringified number on the next line. I
> > thought I could use:
> > 'fseek (fhandle, len, SEEK_CUR);' where len is the
> > returned value from a successful call to fprintf()
>
>The strategy is a mistake.
>
> > However, this doesn't work. Instead I prefer to use:
> >
> > int c;
> > while ((c = fgetc (fhandle)) != EOF)
> > {
> > fputc (c, stdout);
> > }
> >
>
>This works too.
>
> > Any comments?
> >
> > Hope this helps.
> >
> > Michael
>
>
>Ioannis
>
>* Ioannis Vranos
>* Programming pages: http://www.noicys.f2s.com
>* Alternative URL: http://run.to/noicys
>
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|
|
From: Ioannis V. <no...@ya...> - 2001-09-04 16:36:10
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Michael Codadeen
> Sent: Tuesday, September 04, 2001 9:49 AM
> To: dev...@li...
> Subject: RE: [Dev-C++] how to use strings
>=20
>=20
> Hi,
>=20
> Did you get the fprintf to work because I am still having trouble.
>=20
> I have also tried it at work on a HPUX 10.20 aCC compiler but neither=20
> version works for reading from a file.
>=20
> fprintf (stdout, "%s", fhandle);
> fprintf (stdout, "%s", *fhandle);
>=20
> Note, the second version works on the Dev C++ compiler but=20
> reads the first=20
> line only.
fprintf() does NOT read from a file, it *writes* to the file.
An example:
FILE *fp=3Dfopen("/usr/tony/test.txt", w");
...
fprintf(fp, "This is written to the file.");
fprintf(fp, "A number %d\n\n", 7);
/* Do what you have to do */
fclose(fp);
If you want the data to be written immediately to the file after one
fprintf(), you can flush the cache buffer:
fflush(fp); /* It flushes the file buffer. All data are written to the
disk */
>=20
> And yes, I agree there are many ways to move the file pointer=20
> and that=20
> seeking to the end of a string is bad strategy. I was just=20
> trying to get the=20
> thing to read from a file using fprintf().
I know, hat's why it did not work, since fprintf() is for *writing* to
a stream. For example you can write to the monitor:
fprintf(stdout, "Hello new stream world!\n");
>=20
> Michael
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
* Alternative URL: http://run.to/noicys
|
|
From: Michael C. <jd...@ho...> - 2001-09-04 10:00:15
|
Hi Johannes,
I believe that fprintf() does move the file pointer it just looks as though
it isn't, try using ftell() to print the file position.
I believe that because there is a struct being written to the file via
fread() and then a string via fprintf() this is causing the problem as you
suggested.
These functions generally should never be mixed as the problems we are
seeing are caused. Also when reading files between different systems there
are problems concerning the endianess (big endian/little endian) for the
file, allignment, etc. For example, the allignment of an int on one machine
may be different for another. One would have to define a common alligned
struct for writing, similar to the way X11, sockets, and other network
protocols do it.
However, we are only using one os in this case so this shouldn't be a
problem.
I also used fgets() and feof() to test for EOF. The output is only "Hallo
World", and it doesn't see the number on the next line but reports EOF.
char line [256];
while (fgets (line, 256, fhandle) != NULL)
{
printf ("%s", line);
}
if (feof (fhandle))
{
printf ("EOF for fhandle.\n");
}
However, I have also used fscanf()with the field specifier and the
circumflex symbol to ignore upto the newline, etc. This works in certain
circumstances, i.e. only when I specify two scanf() commands as opposed to
one.
fseek (fhandle, 0L, SEEK_SET);
char c1[100];
char c2[100];
char c3[100];
char c4[100];
char c5[100];
/*
// doesn't work - only sees first line
printf ("pos %d\n", ftell (fhandle));
fscanf (fhandle, "%s%s%*[^\n]%*[^'O']%s%s%s", c1, c2, c3, c4, c5);
printf ("%s %s %s %s %s\n", c1, c2, c3, c4, c5);
printf ("pos %d\n", ftell (fhandle));
*/
// works well
printf ("pos %d\n", ftell (fhandle));
fscanf (fhandle, "%s%s%*[^\n]", c1, c2);
printf ("%s %s\n", c1, c2);
fscanf (fhandle, "%*[^'O']%s%s%s", c3, c4, c5);
printf ("pos %d\n", ftell (fhandle));
printf ("%s %s %s\n", c3, c4, c5);
You will notice that the file position is over 200 at the end of the
program. This leads me to conclude that because of the 'crap' after the
first string this causes problems for the string functions, we therefore
need to ignore this stuff.
This doesn't explain why I need two fscanf()s to do this. Although I have
been testing on a HPUX compiler and this should work.
Regards,
Michael
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|
|
From: Johannes P. <joh...@pr...> - 2001-09-04 12:50:12
|
Okay
Problem 2 is actually kinda simple in the sense if I understand you correctly
//SNIP
#include <stdio.h>
#include <alloc.h>
main(int argc, char *argv[]) {
FILE *CheckFile;
int Byte;
unsigned int Checksum;
int read=-1;
int filePos =0;
if ( argc != 2 ) {
printf("usage: checksum filename\n");
exit(1);
}
if ( (CheckFile = fopen(argv[1], "rb")) == NULL ) {
printf("Can't open file: %s\n", argv[1]);
exit(1);
}
/* Initialize the checksum accumulator */
Checksum = 0;
fseek (CheckFile, 0L, SEEK_SET);
char c1[100];
char c2[100];
char c3[100];
char c4[100];
char c5[100];
memset(c1,0,100);
memset(c2,0,100);
memset(c3,0,100);
memset(c4,0,100);
memset(c5,0,100);
printf ("pos %d\n", ftell (CheckFile));
printf("Succesfull assignments : %d c1 : %s\n c2 : %s\n",fscanf
(CheckFile, "%s%s%*[\n]", c1, c2),c1,c2);
//part 1
printf("Succesfull assignments : %d c3 : %s\n c4 : %s\n c5 : %s
",fscanf (CheckFile, "%*[^'O]%s%s%s", c3, c4, c5),c3,c4,c5);
//part 2
//printf("Succesfull assignments : %d c3 : %s\n c4 : %s\n c5 : %s
",fscanf (CheckFile, "%s%s%s%*[\n]", c3, c4, c5),c3,c4,c5);
printf ("pos %d\n", ftell (CheckFile));
fclose(CheckFile);
exit(0);
}
//END SNIP
If you take the above code and run it it does the same as your application.
If you comment part 1 out and uncomment part 2 it reads the next line as
needed. The reason is that you have told the function to move the
cursor until it reaches one of the specified characeters in part 1 that is
a qute (') or a captial O. This is why it runs until past that point as one
of there charcters only
comes after that to test. Enter a capital O in the second line of the program.
Well this is all I can think of now. One thing thou using %s to read a
string into a char array is DANGEROUS for the function will read the string
into it regardless of its size.
To test put in a string in the first line that is MORE than 100 then printf
(well I geuss my program can also be wrong)
if you rather use a char pointer you can read in more that the 100
specified. yust remmeber the free.. here is a code sample to replace in the
above.
//SNIP 2
char *c1;
char c2[100];
char c3[100];
char c4[100];
char c5[100];
// memset(c1,0,100);
memset(c2,0,100);
memset(c3,0,100);
memset(c4,0,100);
memset(c5,0,100);
printf ("pos %d\n", ftell (CheckFile));
printf("Succesfull assignments : %d c1 : %s\n c2 : %s\n",fscanf
(CheckFile, "%s%s", c1, c2),c1,c2);
free(c1);
//END SNIP 2
Well good luck
Johannes
|
|
From: Ioannis V. <no...@ya...> - 2001-09-04 16:39:10
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Michael Codadeen > Sent: Tuesday, September 04, 2001 12:00 PM > To: dev...@li... > Subject: RE: [Dev-C++] how to use strings > > > Hi Johannes, > > I believe that fprintf() does move the file pointer it just > looks as though > it isn't, try using ftell() to print the file position. > > I believe that because there is a struct being written to the > file via > fread() and then a string via fprintf() this is causing the fread() *reads*. fwrite() writes. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys |
|
From: Michael C. <jd...@ho...> - 2001-09-04 14:05:30
|
I read your first mail and have to agree that there may well be undefined
results when you mix and match like we have done.
As for your answer to the second problem, see below for more comments...
>From: Johannes Pretorius <joh...@pr...>
>To: dev...@li...
>Subject: RE: [Dev-C++] how to use strings
>Date: Tue, 04 Sep 2001 14:51:17 +0200
>
>Okay
>Problem 2 is actually kinda simple in the sense if I understand you
>correctly
>
>//SNIP
>
>#include <stdio.h>
>#include <alloc.h>
>
>main(int argc, char *argv[]) {
> FILE *CheckFile;
> int Byte;
> unsigned int Checksum;
> int read=-1;
> int filePos =0;
>
> if ( argc != 2 ) {
> printf("usage: checksum filename\n");
> exit(1);
> }
>
> if ( (CheckFile = fopen(argv[1], "rb")) == NULL ) {
> printf("Can't open file: %s\n", argv[1]);
> exit(1);
> }
>
> /* Initialize the checksum accumulator */
> Checksum = 0;
>
> fseek (CheckFile, 0L, SEEK_SET);
>
> char c1[100];
> char c2[100];
> char c3[100];
> char c4[100];
> char c5[100];
>
> memset(c1,0,100);
> memset(c2,0,100);
> memset(c3,0,100);
> memset(c4,0,100);
> memset(c5,0,100);
> printf ("pos %d\n", ftell (CheckFile));
> printf("Succesfull assignments : %d c1 : %s\n c2 : %s\n",fscanf
>(CheckFile, "%s%s%*[\n]", c1, c2),c1,c2);
>
> //part 1
> printf("Succesfull assignments : %d c3 : %s\n c4 : %s\n c5 : %s
>",fscanf (CheckFile, "%*[^'O]%s%s%s", c3, c4, c5),c3,c4,c5);
*** There is a single quote missing in this, as in my original mail it ***
should read 'O', the character constant for the letter O.
***The following also works but misses the \n.
***fscanf (fhandle, "%s%s%*[^'O']%s%s%s", c1, c2, c3, c4, c5);
> //part 2
> //printf("Succesfull assignments : %d c3 : %s\n c4 : %s\n c5 : %s
>",fscanf (CheckFile, "%s%s%s%*[\n]", c3, c4, c5),c3,c4,c5);
> printf ("pos %d\n", ftell (CheckFile));
> fclose(CheckFile);
> exit(0);
>}
>
>//END SNIP
>
>If you take the above code and run it it does the same as your application.
>If you comment part 1 out and uncomment part 2 it reads the next line as
>needed. The reason is that you have told the function to move the
>cursor until it reaches one of the specified characeters in part 1 that is
>a qute (') or a captial O. This is why it runs until past that point as one
>of there charcters only
>comes after that to test. Enter a capital O in the second line of the
>program.
***As described above, my original example had 'O' in it.
>
>Well this is all I can think of now. One thing thou using %s to read a
>string into a char array is DANGEROUS for the function will read the string
>into it regardless of its size.
>To test put in a string in the first line that is MORE than 100 then printf
>(well I geuss my program can also be wrong)
>
>if you rather use a char pointer you can read in more that the 100
>specified. yust remmeber the free.. here is a code sample to replace in the
>above.
***
I agree. I think a buffer large enough should be allocated for the data to
be placed into. However, in your example you missed out the new() for c1.
The result would be a core dump.
The size for the buffer could be obtained by the number of bytes read and
returned by fread(). As you know fscanf() returns the number of succesfully
assigned input items.
>
>//SNIP 2
> char *c1;
> char c2[100];
> char c3[100];
> char c4[100];
> char c5[100];
>
>// memset(c1,0,100);
> memset(c2,0,100);
> memset(c3,0,100);
> memset(c4,0,100);
> memset(c5,0,100);
> printf ("pos %d\n", ftell (CheckFile));
> printf("Succesfull assignments : %d c1 : %s\n c2 : %s\n",fscanf
>(CheckFile, "%s%s", c1, c2),c1,c2);
> free(c1);
>//END SNIP 2
>
>Well good luck
>Johannes
>
>
I think we have done this subject to death now.
Thanks for all your input.
Michael
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|
|
From: Michael C. <jd...@ho...> - 2001-09-04 17:03:02
|
I think I get the idea now ! ;) My mistake, typo. Should have been fwrite(). Michael >From: "Ioannis Vranos" <no...@ya...> >To: "Dev-C++" <dev...@li...> >Subject: RE: [Dev-C++] how to use strings >Date: Tue, 4 Sep 2001 19:40:28 +0200 > > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf > > Of Michael Codadeen > > Sent: Tuesday, September 04, 2001 12:00 PM > > To: dev...@li... > > Subject: RE: [Dev-C++] how to use strings > > > > > > Hi Johannes, > > > > I believe that fprintf() does move the file pointer it just > > looks as though > > it isn't, try using ftell() to print the file position. > > > > I believe that because there is a struct being written to the > > file via > > fread() and then a string via fprintf() this is causing the > >fread() *reads*. fwrite() writes. > > >Ioannis > >* Ioannis Vranos >* Programming pages: http://www.noicys.f2s.com >* Alternative URL: http://run.to/noicys > > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |