[comp.sys.mac.programmer] Trouble with the File Manager

rmiller@sbcs.sunysb.edu (Robert Miller) (08/26/90)

I've recently written a routine which is supposed to write data
from one of my global data structures to a file.  The problem is,
it is not writing the data.  It *is* writing some of the string 
literals I have defined in another part of my program.  

The code in question looks like this:

count=1;
...
for (i=0....i++)
result = FSWrite(file, &count, &theClause[i]);
...

I looked at this code with the debugger, and at the time of execution
of the FSWrite, count was still equal to 1, and theClause[i] was still
the value I expected, but a different value was written to the file.

And yes, I know there are better ways to write a data structure to a
file than one byte at a time.  I tried them first, and I got the same
result.

Any ideas?

Robert
rmiller@sbcs.sunysb.edu

rmiller@sbcs.sunysb.edu (Robert Miller) (08/26/90)

I've recently written a routine which is supposed to write data
from one of my global data structures to a file.  The problem is,
it is not writing the data.  It *is* writing some of the string 
literals I have defined in another part of my program.  

The code in question looks like this:

count=1;
...
for (i=0....i++)
result = FSWrite(file, &count, &theClause[i]);
...

I looked at this code with the debugger, and at the time of execution
of the FSWrite, count was still equal to 1, and theClause[i] was still
the value I expected, but a different value was written to the file.

I'm using Think C 4.0.

And yes, I know there are better ways to write a data structure to a
file than one byte at a time.  I tried them first, and I got the same
result.

Any ideas?

Robert
rmiller@sbcs.sunysb.edu

hawley@adobe.COM (Steve Hawley) (08/28/90)

In article <1990Aug25.215438.17449@sbcs.sunysb.edu> rmiller@sbcs.sunysb.edu (Robert Miller) writes:
|The code in question looks like this:
|
|count=1;
|...
|for (i=0....i++)
|result = FSWrite(file, &count, &theClause[i]);
|...
|And yes, I know there are better ways to write a data structure to a
|file than one byte at a time.  I tried them first, and I got the same
|result.


If count isn't a long, you're in trouble.

Steve Hawley
hawley@adobe.com
-- 
"I can always telephone, but I can't tell it much."
	-Roy Blount

russotto@eng.umd.edu (Matthew T. Russotto) (08/30/90)

In article <1990Aug25.215934.17867@sbcs.sunysb.edu> rmiller@sbcs.sunysb.edu (Robert Miller) writes:
>
>count=1;
>...
>for (i=0....i++)
>result = FSWrite(file, &count, &theClause[i]);
>...
What is count?  It should be a _long_.
--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
      .sig under construction, like the rest of this campus.