Hi all,

I have a disk file define as

TCHAR szTempFile[MAX_PATH];

What I want to do is, read that file into memory stream. To a buffer. How can I do it.

But on what I confused is that file data type of TCHAR.

Can I used it as ifstream.

No you can't, you'll have to convert it first. If your program ISN'T compiled with unicode: ifstream myfile ((char*)szTempFile); If you ARE using unicode:

#include <cstdlib>
[.......]
const int BUFSIZE = 100;
char buffer[BUFSIZE];
wcstombs(buffer, szTempFile, BUFSIZE );
ifstream myfile (buffer);

Thanks for the replay.

But I do it using ifstream, and seems it works fine.

I got all those things to done because of the following example.

XML Writer in C++

Can you just see it.

What I have done is, output stream write to a disk file and then read the file to memory. It's odd.

So i try to directly write that stream to memory. But wired with it, I can't use char buffer for that.

Can you help me to do it. Any clue..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.