C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Iron Speed
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old May 5th, 2008, 05:08 AM
kasilas kasilas is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 kasilas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 56 sec
Reputation Power: 0
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);
        }
The example file it accesses is a tab limited labvew output file (.lvm). Basically it's a column of two tab delimited numbers with a 20 line header at the top.

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

Reply With Quote
  #2  
Old May 5th, 2008, 06:01 AM
Icon's Avatar
Icon Icon is offline
Command Line Warrior
Click here for more information.
 
Join Date: Sep 2005
Posts: 595 Icon User rank is Private First Class (20 - 50 Reputation Level)Icon User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 10 h 41 m 27 sec
Reputation Power: 3
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.
Comments on this post
kasilas agrees!
__________________
Current project: roborally

Reply With Quote
  #3  
Old May 5th, 2008, 02:16 PM
kasilas kasilas is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 kasilas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 56 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > File IO - Strange limit on input file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway