Objectmix
Tags Register Mark Forums Read

how to reads two files at the same time : c++

This is a discussion on how to reads two files at the same time within the c++ forums in Programming Languages category; I have to to do an application with accelerometers,inside a loop while(1) I need to read 2 files each file contains the actual information of an accelerometer, I think there is a method that is better than open the first and read its information, then close it, and open the seconde and read it and then close it and return to the first .... This method is very slow, is there a better method??...


Object Mix > Programming Languages > c++ > how to reads two files at the same time

c++ comp.lang.c++ usenet archive

Reply

 

LinkBack Thread Tools
  #1  
Old 04-16-2009, 09:14 AM
Junior Member
 
Join Date: Apr 2009
Posts: 0
eng2009 is on a distinguished road
Default how to reads two files at the same time

I have to to do an application with accelerometers,inside a loop while(1) I need to read 2 files each file contains the actual information of an accelerometer, I think there is a method that is better than open the first and read its information, then close it, and open the seconde and read it and then close it and return to the first ....
This method is very slow, is there a better method??
  #2  
Old 09-29-2009, 01:17 AM
Junior Member
 
Join Date: Sep 2009
Posts: 1
Rebecca is on a distinguished road
Default Re: how to reads two files at the same time

Use fgetpos() and fsetpos(), which are designed for use with huge files.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>

int main()
{
int c;
fpos_t pos;
FILE* f = fopen( "myfile", "r+b" );
while (true)
{
fgetpos( f, &pos );
c = fgetc( f );
if (c == EOF) break;
c = encrypt( c );
fsetpos( f, &pos );
fputc( c, f );
}
fclose( f );
return 0;
}

That should definitely work...


Thanks and Regards
Rebecca Phillips
Reply

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
Re: PS3 droplet called from command line inXP reads in files but does not execute action usenet Adobe Photoshop 0 09-09-2008 02:25 PM
Re: PS3 droplet called from command line inXP reads in files but does not execute action usenet Adobe Photoshop 0 09-09-2008 01:46 PM
Re: PS3 droplet called from command line inXP reads in files but does not execute action usenet Adobe Photoshop 0 09-09-2008 08:15 AM
Nonrepeatable Reads and Phantom Reads usenet Weblogic 3 10-27-2006 05:38 AM
Service that Reads/Writes Files/SQL Server usenet DOTNET 1 04-16-2004 10:59 AM


All times are GMT -5. The time now is 08:42 AM.

Managed by Infnx Pvt Ltd.