Click here to Skip to main content
16,007,885 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Parallel port address auto detect Pin
jfk_lili27-May-04 22:47
jfk_lili27-May-04 22:47 
GeneralFILE IO Pin
demasoni.com27-May-04 14:42
demasoni.com27-May-04 14:42 
GeneralRe: FILE IO Pin
Anthony_Yio27-May-04 16:50
Anthony_Yio27-May-04 16:50 
GeneralRe: FILE IO Pin
demasoni.com27-May-04 19:21
demasoni.com27-May-04 19:21 
GeneralRe: FILE IO Pin
Anthony_Yio27-May-04 19:44
Anthony_Yio27-May-04 19:44 
GeneralRe: FILE IO Pin
demasoni.com28-May-04 11:57
demasoni.com28-May-04 11:57 
GeneralRe: FILE IO Pin
toxcct27-May-04 21:41
toxcct27-May-04 21:41 
GeneralRe: FILE IO Pin
markkuk27-May-04 22:59
markkuk27-May-04 22:59 
Why are you reading the file twice and throwing away the bytes read in the first pass? Here's a function to read all the bytes of a file in one pass to a C++ std::vector.
#include <fstream>
#include <vector>
#include <string>

using namespace std;
const int SizeBuff=1024;
typedef unsigned char BYTE;

/* inputFile : name of the file to read
 * buffer : contents of the file are appended to this vector
 */
void readFile(const string& inputFile, vector<BYTE>& buffer)
{
	ifstream inputStream;
	vector<BYTE> tmpBuf(SizeBuff);
	streamsize bytesRead;

	inputStream.open(inputFile.c_str(), ios::in|ios::binary);
	while(inputStream) {
		inputStream.read(reinterpret_cast<char*>(&tmpBuf[0]), SizeBuff);
		bytesRead=inputStream.gcount();
		if(bytesRead > 0) {
			buffer.insert(buffer.end(), tmpBuf.begin(), 
			tmpBuf.begin() + bytesRead);
		}
	}
        inputStream.close();
}

GeneralRe: FILE IO Pin
demasoni.com28-May-04 3:55
demasoni.com28-May-04 3:55 
GeneralRe: FILE IO Pin
markkuk28-May-04 12:19
markkuk28-May-04 12:19 
GeneralRe: FILE IO Pin
demasoni.com30-May-04 8:23
demasoni.com30-May-04 8:23 
GeneralActiveX licensing Pin
mirano27-May-04 12:27
mirano27-May-04 12:27 
GeneralTab Key Pin
Grahamfff27-May-04 12:26
Grahamfff27-May-04 12:26 
GeneralRe: Tab Key Pin
Anthony_Yio27-May-04 17:27
Anthony_Yio27-May-04 17:27 
GeneralRe: Tab Key Pin
Ryan Binns27-May-04 18:33
Ryan Binns27-May-04 18:33 
GeneralRe: Tab Key Pin
sweep12328-May-04 0:34
sweep12328-May-04 0:34 
GeneralRe: Tab Key Pin
Ryan Binns28-May-04 0:46
Ryan Binns28-May-04 0:46 
GeneralRe: Tab Key Pin
Anthony_Yio28-May-04 19:10
Anthony_Yio28-May-04 19:10 
GeneralRe: Tab Key Pin
Ryan Binns29-May-04 3:41
Ryan Binns29-May-04 3:41 
GeneralCreateProcessWithLogonW Pin
cobyjone27-May-04 10:25
cobyjone27-May-04 10:25 
GeneralRe: CreateProcessWithLogonW Pin
Rob Manderson27-May-04 12:41
protectorRob Manderson27-May-04 12:41 
GeneralRe: CreateProcessWithLogonW Pin
cobyjone28-May-04 3:48
cobyjone28-May-04 3:48 
GeneralChanging Size Font and Vertical Scroll Bar Pin
Eversman27-May-04 10:16
Eversman27-May-04 10:16 
GeneralRe: Changing Size Font and Vertical Scroll Bar Pin
gUrM33T27-May-04 15:07
gUrM33T27-May-04 15:07 
GeneralUsing Excel data in VC++ 6.0 Pin
greg8927-May-04 9:31
greg8927-May-04 9:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.