| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
File IO - Strange limit on input file
Hi, I am writing a simple voltage pulse height analysis program but it has a a strange limit on input file size. I can demonstrate the limit with the following code:
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
long pos=0;
long int iii=0;
long double xval;
long double yval;
string line;
ifstream infile("example.lvm");
//Just skipping Header
while(iii<20)
{
iii++;
getline(infile,line);
cout<<line<<endl;
}
while(!infile.eof())
{
pos=infile.tellg();
infile>>xval;
infile>>yval;
iii++;
if(iii%2000==0)cout<<"Position is "<<pos<<" Y value is "<<yval<<endl;
}
infile.close();
return(0);
}
So why, o why, does the get pointer go to about 48000000 and then decide to go to -1? For example, the above program (compiled on Visual studio express edition 2008) gives the output: [Get pointer moving correctly above this] ... ... Position is 47616162 Y value is -10.5593 Position is 47712162 Y value is -10.5593 Position is 47808162 Y value is -10.5593 Position is 47904162 Y value is -10.5593 Position is 48000162 Y value is -10.5593 Position is -1 Y value is -10.5593 Position is -1 Y value is -10.5593 Position is -1 Y value is -10.5593 Position is -1 Y value is -10.5593 [Obviously all the same below this] Does anyone know the reason for this limit and a way around it. Thanks for any help |
|
#2
|
||||
|
||||
|
tellg returning -1 indicates that an error occurred. I guess that it happens when reading one of the two values, xval or yval. Try to find the exact spot where it starts failing in the file. Look at the two numbers before that line or check if there are some weird characters trailing that line.
__________________
Current project: roborally |
|
#3
|
|||
|
|||
|
Cheers I found the problem. Labview's signal express streaming samples have every millions lines a break in the files like this.
... ... ... 3.29241370521874520E+9 -1.05592950995154200E+1 3.29241370521874760E+9 -1.05592950995154200E+1 3.29241370521875000E+9 -1.05592950995154200E+1 Channels 1 Samples 1000000 Date 2008/04/30 Time 16:21:51.421877 X_Dimension Time X0 0.0000000000000000E+0 Delta_X 2.500000E-6 ***End_of_Header*** X_Value Voltage - Dev1_ai0 Comment 3.29241371142187790E+9 -1.00144452341074800E+1 3.29241371142188020E+9 -9.18558163543579200E+0 I feel a bit silly for asking now but cheers anyway. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > File IO - Strange limit on input file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|