more info for saving int array to disk 
Author Message
 more info for saving int array to disk

What i am trying to do is have a pre and post test 10
questions long, they will be taken at seperate times and
i want the ability to save the pre answers to disk for
comparison to the post answers later. so the program will
have to read to answers back in and compair them. it just
seems like  converting to a string for saving and parsing
the string and converting back to int is a long way
around this. (The questions are multiple choice)

How can i save an array of 10 integers to disk?
Im convering them to characters and saving them into a
buffer using wsprint() but this seems like a bad way to
do this. Any samples you could point me to would be great.

would you loop over writefile? (May be way off)

int iBuffer[10] ;
Buffer[0] = 5
Buffer[1] = 7
Buffer etc...

for( int i = 0; i < 10; i++)
{
WriteFile(hFile2,                      
          iBuffer[i],                                  
          4,    
          &dwBytesWritten                          
          NULL) == FALSE)

Quote:
}

.


Tue, 01 Feb 2005 00:33:46 GMT  
 more info for saving int array to disk
You can write the whole buffer in one go:

WriteFile(hFile2, iBuffer, 10*sizeof(int), &dwBytesWritten, NULL);

--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> What i am trying to do is have a pre and post test 10
> questions long, they will be taken at seperate times and
> i want the ability to save the pre answers to disk for
> comparison to the post answers later. so the program will
> have to read to answers back in and compair them. it just
> seems like  converting to a string for saving and parsing
> the string and converting back to int is a long way
> around this. (The questions are multiple choice)

> How can i save an array of 10 integers to disk?
> Im convering them to characters and saving them into a
> buffer using wsprint() but this seems like a bad way to
> do this. Any samples you could point me to would be great.

> would you loop over writefile? (May be way off)

> int iBuffer[10] ;
> Buffer[0] = 5
> Buffer[1] = 7
> Buffer etc...

> for( int i = 0; i < 10; i++)
> {
> WriteFile(hFile2,
>   iBuffer[i],
>   4,
>   &dwBytesWritten
>   NULL) == FALSE)
> }

> .



Tue, 01 Feb 2005 02:29:02 GMT  
 more info for saving int array to disk
Thats works perfect, thanks

Quote:
>-----Original Message-----
>You can write the whole buffer in one go:

>WriteFile(hFile2, iBuffer, 10*sizeof(int),

&dwBytesWritten, NULL);
Quote:

>--
>With best wishes,
>    Igor Tandetnik

>"For every complex problem, there is a solution that is
simple, neat,
>and wrong." H.L. Mencken



>> What i am trying to do is have a pre and post test 10
>> questions long, they will be taken at seperate times
and
>> i want the ability to save the pre answers to disk for
>> comparison to the post answers later. so the program
will
>> have to read to answers back in and compair them. it
just
>> seems like  converting to a string for saving and
parsing
>> the string and converting back to int is a long way
>> around this. (The questions are multiple choice)

>> How can i save an array of 10 integers to disk?
>> Im convering them to characters and saving them into a
>> buffer using wsprint() but this seems like a bad way to
>> do this. Any samples you could point me to would be
great.

>> would you loop over writefile? (May be way off)

>> int iBuffer[10] ;
>> Buffer[0] = 5
>> Buffer[1] = 7
>> Buffer etc...

>> for( int i = 0; i < 10; i++)
>> {
>> WriteFile(hFile2,
>>   iBuffer[i],
>>   4,
>>   &dwBytesWritten
>>   NULL) == FALSE)
>> }

>> .

>.



Tue, 01 Feb 2005 04:15:20 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. saving int array to Disk

2. int pointer to int array

3. int to int array problem

4. Converting a string array to a int array

5. Save HashTable to disk.

6. Save a whole ImageList to Disk

7. from disk to int[], vice-versa...

8. homework help scanning info from disk?

9. how do I force my program to save to disk before exit

10. Help saving bitmap to disk

11. saving trees/lists to disk - any easy way?

12. Saving to disk?

 

 
Powered by phpBB® Forum Software