// Using FSWrite to Write to a File
// A simple demos showing how to write to a file using FSWrite. This // demo creates a new file and fills it with the alphabet. This is
// intended for use as an example code and so contains a minimum of
// error checking
#define ARRAY_SIZE 26
// Assumes inclusion of
#include
void ToolBoxInit (void);
void ToolBoxInit ()
{
}
main()
{
char anArray[ARRAY_SIZE]; // here 's the array that we will write
// out to the file
short fRefNum;
long count;
short i;
ToolBoxInit();
// Fill the array with the letters of the alphabet
for (i = 0; i < ARRAY_SIZE; i++)
anArray[i] = i + 'a';
SFPutFile(where, "\p", "\pUntitled", nil, &reply); if (reply.good)
{
if (!err) {
count = ARRAY_SIZE;
err = FSWrite(fRefNum, &count, &anArray);
if ((err) || (count != ARRAY_SIZE) )
printf ("Write to file unsuccessful\n");
}
}
}