|
How about this way,
std::string strRTF(ss.GetString());
ss is the CString.
But, when I use
cout << strRTF;
I got the following compiled error.
binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
What can be the issue.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: How about this way,
std::string strRTF(ss.GetString());
That's fine - what does GetString() return? If it's a CString, then
the only thing I don't like is CString is a generic (template) type
and std::string is not. The code won't be portable to Unicode builds.
This is maybe better in that case...
typedef std::basic_string<tchar> tstring;
...
tstring strRTF(ss.GetString());
Eranga Thennakoon wrote: But, when I use
cout << strRTF;
How about:
cout << strRTF.c_str();
Mark
Mark Salsbery
Microsoft MVP - Visual C++
modified on Thursday, December 13, 2007 10:35:25 PM
|
|
|
|
|
Mark Salsbery wrote: what does GetString() return?
It return a string, standard string.
Mark Salsbery wrote: c_str()
You are right, I have to null-terminated the string.
I appreciate your help all the time...
Eranga
|
|
|
|
|
I have two applications running on one computer. The first app imports data from elsewhere, parses it, and writes out several files using CreateFile and WriteFile to a directory. The second app reads each of these files from the first app using FindFirstFile, CreateFile and ReadFile, and does further processing.
The data written to these files is fairly big in each case (~8 MB), so each file write can take 2-3 seconds. Also, each batch of files can potentially be large (say 100 or more). So, while the first app is busy writing each file, the second app should be able to take the first file it finds (via FindFirstFile), and open and read it. The problem is, ReadFile doesn't return for that first file until the first app has written out ALL of its files. So this ReadFile call in essence hangs for a few minutes, possibly causing havoc elsewhere in the app.
I'm closing my file handles properly in the first app (at least I think I am), so there shouldn't be any reason for ReadFile to wait on file writes that are on different files in the same directory. Is there some "feature" in the Win32 file API that would explain this behavior? I'm writing the files using FILE_FLAG_SEQUENTIAL_SCAN and sharing disabled, if it matters; I've also played with FILE_FLAG_NO_BUFFERING to attempt to improve performance.
|
|
|
|
|
When writing, are you using the CreateFile() and CloseHandle() pair for each file before
moving on to the next file?
Also, I'm pretty sure the files will be found with FindFirstFile() before they are closed
(they show up in explorer while being written ).
Does the reader take this into account, possibly looking for a failure to open due to no shared access?
Mark
|
|
|
|
|
Wouldn't it be easier for the first application to just send a simple message to the second application telling it that file X is finished? Otherwise, FindFirstFile() is going to find files that exist but are empty or locked.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You better write the files one by one with *.tmp extension and when ready rename it. This makes sure that only ready files are found.
Greetings from Germany
|
|
|
|
|
Hello
I want to work with files unmanaged.
I've been using fstream for file i/o but the problem is that if the file is greater than the maximum value of long I am not able to seek within it since the offset in the seek command doesn't accept values greater than long.
Is there any other way I should work with files ? (unmanaged, not using system.dll)
Clint
|
|
|
|
|
|
Has Windows Vista got graphics routines to read from JPG images to internal image mode, and to output from internal image mode into JPG mode? If so, how does Visual C++ call those routines?
|
|
|
|
|
GDI+[^] wll handle JPEGs plus several other types.
It's included on XP+ operating systems and available as a redistributable for versions
back to Windows 98.
If you use the CImage class[^], which uses GDI+ to load and save images,
you can load and save images with just a couple lines of code.
You can also look at the CImage class source code to see how it uses GDI+.
Mark
|
|
|
|
|
So far my atempts at telling Visual C++ programs to display text have displayed mostly Chinese characters, mixed with occasional Japanese katakana and Arabic letters.
I have realised that I may have run foul of a confusion between the ordinary 8-bit characters that I have known since the beginnings of desktop computers, and the Windows 16-bit characters that include national character sets (including Chinese characters). Please, starting with
char*s = "The quick brown fox jumps over the lazy dog's back.";
(which is 51 characters (not counting the terminating /000 character)), how can I tell the program to convert that into the Roman-alphabet 16-character form so the program will display that in the Roman alphabet?
|
|
|
|
|
I don't know, ever heard of UNICODE ?
on another tangent, there is a macro, I think, called A2W that converts LPSTR to LPWSTR, you can start by looking at those and start your education from there.
|
|
|
|
|
I need a small function or code to do interpolation. Knowing Y(Xi) to fine y(x) for a give x.
If you have a code please share with me.
Thanks
|
|
|
|
|
I know you get fast service here, but surely google is faster: link[^]
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
y = (x-x1)*(y2-y1)/(x2-x1)+y1;
|
|
|
|
|
Thanks for your message.
I know the math behind a interpolation. Now I am looking a ready code or function.
|
|
|
|
|
He's given you the code. Just wrap that into a function, with the relevant parameters, returning the relevant result.
Barring him coming round to your office desk, there's not much more he can do for you.
Iain.
|
|
|
|
|
Interpolation is heavy duty if you have complex functions. You better implement an acurate function.
Greetings from Germany
|
|
|
|
|
Thanks and greeting from US.
I am looking for some code and save me to write again.
|
|
|
|
|
If you need an interpolation function, you need to specify what exactly you need to interpolate.
Ie. Linear? Quadratic? Cubic? Higher Polynomials?
|
|
|
|
|
Thanks.
Spline will be good.
|
|
|
|
|
I often copy a full directory of a proiject to another director and change the programs
to another application, but I still have to use the same project name. When I got the new compiled
excutable file. its name is still the same as the old one.
This is a MFC program project. I do want to change the project name and get new name for the new application. I do not knw how to change the project and program excutable names.
Thanks
|
|
|
|
|
Edit the project setting: Linker/General/Output File
It may be a good idea to go through all the settings of the copied project and
make sure there's no settings that still relate to the old project
Mark
|
|
|
|
|