473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

fstream issue reading files.

Hi All,

Sorry if this is a question covered before but I'm having a torid time trying to get an fstream to behave. Essentially when I embed the code snipet below into a program, and give it a file to load, the stream stops loading after 62987 bytes are read in. It claims to have encountered an end of file, however I've tried it with a number of files, including plain text ones, and if they are greater than this value in size, it fails to load. Please help ?

Expand|Select|Wrap|Line Numbers
  1.   strstreambuf tmpbuf;
  2.   iostream bufferedStrm(&tmpbuf);
  3.   ifstream strm(lc_strFileName.GetBuffer(lc_strFileName.GetLength()),ios::in|ios::binary);
  4.   if (!strm.fail())
  5.   {
  6.         bufferedStrm.operator <<(strm.rdbuf());    
  7. }

A little more background to platform, I'm running on an XP box, developing under Visual Studio C++ .Net. Any help would be greatly appreciated.

Regards

Neil.
Mar 1 '07 #1
1 1505
sicarie
4,677 Expert Mod 4TB
Hi All,

Sorry if this is a question covered before but I'm having a torid time trying to get an fstream to behave. Essentially when I embed the code snipet below into a program, and give it a file to load, the stream stops loading after 62987 bytes are read in. It claims to have encountered an end of file, however I've tried it with a number of files, including plain text ones, and if they are greater than this value in size, it fails to load. Please help ?

Expand|Select|Wrap|Line Numbers
  1.   strstreambuf tmpbuf;
  2.   iostream bufferedStrm(&tmpbuf);
  3.   ifstream strm(lc_strFileName.GetBuffer(lc_strFileName.GetLength()),ios::in|ios::binary);
  4.   if (!strm.fail())
  5.   {
  6.         bufferedStrm.operator <<(strm.rdbuf());    
  7. }

A little more background to platform, I'm running on an XP box, developing under Visual Studio C++ .Net. Any help would be greatly appreciated.

Regards

Neil.
You're just loading everything into a buffer? No getline or anything to clear the buffer after youre done with it? I'm guessing then you're hitting the stack limit, any other thoughts on this?
Mar 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out |...
6
by: Armando | last post by:
Hallo ! I habe some error in my programm,because i use <fstream.h>,I want to use <fstream> but i don´t know which fonctions i must modify in my program ? Thanks you for your help. Armando.
7
by: Computer Whizz | last post by:
Hi, I was just wondering if someone would like to comment on these two issues. I had a 15 minute wander around some sites and was curious about loading files (plain ASCII I think will do for a...
7
by: jccorreu | last post by:
I've got to read info from multiple files that will be given to me. I know the format and what the data is. The thing is each time we run the program we may be using a differnt number of files,...
6
by: wiso | last post by:
My problem is this (from: http://www.cplusplus.com/ref/iostream/fstream/open.html) #include <fstream> using namespace std; int main() { fstream f;
2
by: jjcp | last post by:
I would like to say thanks in advance for insight anyone can shed on this for me. Long story short from time to time I need to us C++ to take a list of file and make an index out of them in...
6
by: Gaijinco | last post by:
Should this do something? #include <fstream> #include <string> int main() { std::fstream filestr ("test.txt", std::fstream::in | std::fstream::out); std::string s="";
2
by: mauricesmith42 | last post by:
Sorry i know this is rather large to be posting, but in order to understand the question you have to see all the code //#include <windows.h> //needed for opening folders #include...
6
by: canilao | last post by:
Hi All, So I ran into an issue with using the ! operator with fstream: // Make sure the file is ready to be read before we move on. 1: fstream fileStream; 2: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.