GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Jan-2008, 13:36
tootypegs tootypegs is offline
Junior Member
 
Join Date: Nov 2007
Posts: 32
tootypegs has a little shameless behaviour in the past

Streaming problems


Hi, im having problems with my code in the respect that nothing happens lol. I want to stream bytes from 'usbimage2.txt' into the buffer until the buffer is full. I then want to stream the buffer into 'new.txt'. I thought that this syntax was correct but nothing happens, can anyone see what im doing wrong?


thanks

Code:
char buffer[100]; myFile.seekg (start_byte,std::ios::beg) ; ifstream myFile ("C:\\temp\\usbimage2.txt", ios::in | ios::binary); myFile.read (buffer, 100); fstream myFile2 ("new.txt", ios::out | ios::binary); myFile2.write (buffer, 100);
  #2  
Old 08-Jan-2008, 15:16
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Streaming problems


Quote:
Originally Posted by tootypegs
...nothing happens lol...

Are you really lolling?

Oh, well, here are a few observations:


1. That code uses myFile before it is declared. What code are you really using? If by "nothing happens," you mean that it doesn't compile, then maybe you should show us exactly what you are using and tell us exactly what happens when you try to do whatever it is that you are trying to do. If it does compile but something unwanted happens when you try to execute (or "nothing" happens), then post the program, not just a couple of lines that won't compile. Be sure to tell us enough about what it is that you don't understand so that we might be able to help you.

General programming recommendations:

2. You should always test to see that streams are opened successfully before using. (Yes, always.)

3. You should always test the state of a stream after attempting to read. (Yes, always.) Same for writing.

4. You can make a loop using the read and write statements that you showed and make it do what you want it to.

but...

5. How about showing us the complete code so that we won't have to guess at the many, many (many) things that you could be doing wrong? How the heck could you think anyone could help you unless you show us how you are trying to do the deed?

Regards,

Dave
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recent problems with antivirus programmes steven_symantec Member Announcements, Advertisements & Offers 3 14-Feb-2008 22:22
Problems while burning CD's netnut Computer Software Forum - Windows 16 18-Jan-2008 00:45
Challenge problems plz help plz crazyABOUTyou C++ Forum 3 24-Apr-2007 11:32
out of memory problems pixienick MS Visual C++ / MFC Forum 1 25-Apr-2006 13:37
Chaintech Geforce 5600 FX problems bartster74 Computer Hardware Forum 8 04-May-2004 14:16

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:31.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.