|
Hi,
The code I am writting: cout<<"Our start time is"<
|
|
|
|
|
int(floor(iDur/60)) and iDur%60 will give you what you want, won't it ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I know this isn't a question and this probably doesn't belong here but I figured what better place to put it. I'd like to say Thank you(yet again) to DavidCrow for the tremendous help he gave me when I needed it. And just have to say what a person you must be. To have the patience you have. I hope one day to be able to help others the way you've helped me thank you.
|
|
|
|
|
There are a number of very helpful people on this site, and David is definitely one of them. It's good of you to say "Thank you," as so many of us often fail to do.
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
After all he is MrNice.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Hello,
I downloaded a source code in sourceforge.net and rebuild it to learn what it does in system!
It requires too many: Service Pack 3 for Visual C 6.0, DirectX SDK, DDK, and Processor Pack for Visual C 6.0 too.
But after passing many error in compiling, building its dependencies, I come to the last component: the main program.
In the "stdafx.h" file, it includes many header, but the important is:
<br />
#include <vector><br />
#include <string><br />
<br />
using namespace std;<br />
<br />
and VC say error when compiling the first file stdafx.cpp:
<br />
<br />
--------------------Configuration: DScaler - Win32 Release--------------------<br />
Compiling...<br />
StdAfx.cpp<br />
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\istream(557) : error C2059: syntax error : 'catch'<br />
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\istream(557) : error C2143: syntax error : missing ';' before '{'<br />
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\istream(559) : error C2712: Cannot use __try in functions that require object unwinding<br />
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\istream(578) : error C2059: syntax error : 'catch'<br />
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\istream(578) : error C2143: syntax error : missing ';' before '{'<br />
Error executing cl.exe.<br />
<br />
DScaler.exe - 5 error(s), 0 warning(s)<br />
<br />
If I comment #include <string>, I can pass this file (remember it is stdafx.cpp), but I will get many many other errors in next files.
So please help me to fix this error!
PS. I download DScaler from sourceforge.net. Thank you very much!
|
|
|
|
|
A DirectX program is clearly a fairly advanced thing to be pulling apart, especially if you don't have DX already ( i.e. are not into that sort of stuff ).
It's possible that there's a compliler setting you need to turn on for try.catch to work ( I'm going from memory here ). Otherwise, could you clarify what headers you're including ? You didn't check Do not treat <'s as HTML tags, nor did you use the buttons below to enter < for <, etc, so they got stripped as HTML.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Firstly, thank you very much for your reply, Chris! I'm very very happy when receive your reply...
This is the include code:
#include <vector>
#include <string>
using namespace std;
If I comment the sencond include code, I can pass the first compiling for stdafx.cpp, but I will get many many errors in next files.
I think that there are some wrong options in C/C++ tab of the property of project. But this project is original from its source. I've just re-compiled it only.
Please help me, Chris! Thank you very much!
|
|
|
|
|
The problme is probably due to namespace pollution. As your doing a using namespace std you may find you end up adding a lot of symbols/names which clash with some of the symbols/names in your projects. Try reducing the amount beinf incuded by using:
using std::string;
using std::vector;
Globally includint entire namespaces like this may be good in the short term, but can bite you on the a$$ later on. We had a similar problem here recently.
Roger Allen - Sonork 100.10016
Strong Sad:
Clever I am? Next to no one.
Undiscovered and soggy.
Look up. Look down. They're around.
Probably laughing. Still, bright, watery.
Listed among the top. Ten.
Nine. Late night. Early morn.
Early mourn. Now I sleep.
|
|
|
|
|
Can't resolve this problem....
|
|
|
|
|
Hi,
If I have an app with a dialog resource is there an easY way to export the dialog
from one app and import it into the other app? Or do I have to re add it and then move the code for it over to the new application.
Regards,
axe
|
|
|
|
|
Open the .rc file as text and copy and paste it over. Then make sure the resource ID's referred to in it are in the resource ID file of the new project.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am working with Dialogbased application.I was created one Modalless Dialogbox part of the application.Now How to send the Message from Modalless Dialogbox window to MainDialog whenever modellessDialogbox closed?Pl Tell me How to implement the SendMessage function?
dadsadasd
|
|
|
|
|
Why not hold a pointer to the main dialog in the modeless dialog and then in OnClose, call a function you provide in the main dialog ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Better to store the handle to main dialog window. The SendMessage to that window handle.
greatest thing is to do wot others think you cant suhredayan@omniquad.com>
messenger :suhredayan@hotmail.com
|
|
|
|
|
Right before the modeless dialog is destroyed, call GetParent()->SendMessage(...) . You'll then need a corresponding message handler in the parent (modal) dialog.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I was implemented Like.
1.In the Parent DialogBox I declared like
#define GOODBYE WM_USER+1
ON_COMMAND(GOODBYE,OnGoodBye)
LRESULT OnGoodBye(WPARAM wparam,LPARAM)
{
//implementation
}
2.In the CHildDIalog WM_CLOSE
void OnCLose()
{
GetParent()->SendMessage(GOODBYE,0,0);
DestroyWindow();
}
I was implemented Like that. But I am getting the Result?
How ?
dadsadasd
|
|
|
|
|
asv wrote:
I was implemented Like that. But I am getting the Result?
Ok, so what seems to be the problem?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,
I'm writing about 20kb of data into a binary file, but at some point during the file output (usually after a certain amount of objects are required to be saved to disk), some form of corruption occurs. Can anyone help with this? Here is some example code:
<br />
ofstream myFile(lpszPathName, ios::binary || ios::trunc);<br />
<br />
<br />
myFile.write((char*)(&version), sizeof(int));
myFile.write((char*)(&w0.numMeshes), sizeof(int));
myFile.write((char*)(&w0.numLights), sizeof(int));<br />
myFile.write((char*)(&p.pos.x), sizeof(float));<br />
myFile.write((char*)(&p.pos.y), sizeof(float));<br />
myFile.write((char*)(&p.pos.z), sizeof(float));<br />
<br />
for(int m = 0; m < w0.numMeshes; m++) <br />
{<br />
myFile.write((char*)(&w0.world_meshes[m]->numFaces), sizeof(int));<br />
myFile.write((char*)(&w0.world_meshes[m]->numVerts), sizeof(int));<br />
myFile.write((char*)(&w0.world_meshes[m]->numNormals), sizeof(int));<br />
etc... etc... going through all mesh faces, vertices and what not, and then finally a myFile.close().
Exactly the same happens for reading, but using file.read() instead. The read function is exactly the same as it's copied & pasted with just swapping of myFile.write to file.read, although there are a few initializations in between the reading lines which are not there during the writing lines.
It seems to be completely random, and I know this isn't possible in programming! It mostly happens when 12 objects need to be required to save to disk, although sometimes it works fine up to an infinite amount, other times, 5 or 6 objects can be written and the corruption starts.
I'm thinking along the lines of some kind of buffer error happening once it reaches a certain size? If anyone can help me on this problem I would be so greatful.
Yours desperately,
Nathan
|
|
|
|
|
From your code example, I understand that the version and other variables are of type integer , float or similar. Also, according to the writing function, the input is supposed to be a pointer to a character string.
As far as I know, a direct conversion like this is not going to work. What gets written into the file is a character representation of the number. This means, that the integer is readed, converted to it's equivalent character code, and written into the file. Now, as a character can only have 8 bits, this works until a certain number limit is reached. When this happens, an over/underrun in the bit sequence happens (INT_MAX becomes INT_MIN, for example) and the character value written into the file no longer represents the actual data.
What you should do, instead, is use an intermediate buffer, into which you convert the value (int-to-string / long-to-string). There is no float-to-string conversion, as far as I know.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thank you for your further explanation! I must have understood the concept wrong, as I imagined that sizeof(type); would have specified exactly the size in bits to be written in, and that the (char*) cast at the start was only required to write to the file.
|
|
|
|
|
I think that the conversion to char* is OK. Because integer is converted to an array of chars (with appropriate length), no information is scratched.
But for storing and loading basic data types you could use operators >> and << instead of write() and read() . It's more readable
I know, that these paragraphs probably don't solve all of your problem. So write us, what does your corruption mean? It causes an error message or the read data are different from the written data?
Robert-Antonio
"A piece of paper is an ink-lined plane.
An inclined plane is slope up.
A slow pup is a lazy dog.
Q.E.D.: A piece of paper is a lazy dog."
|
|
|
|
|
Robert A. T. Káldy wrote:
I think that the conversion to char* is OK. Because integer is converted to an array of chars (with appropriate length), no information is scratched.
Unfortunately I fail to see the reason of why this would be correct ? I'm not saying it is wrong, but I just don't know how it could work ?
The way I see it is that the pointer received by the write function specifies the starting point, and the size parameter tells how many bytes are supposed to be copied. Afterall, a char basic type is of size 1 byte on the Microsoft C++ environment.
So, the function starts from the beginning address to copy data into the file on a byte-by-byte basis. It reads one byte of data, and writes it down. An integer is already 4 bytes long, so this won't pose a problem if the integer is in limit of 1 byte dimension. But any number greater than 128 or smaller than -127 (unsigned char) is considered out-of-bounds, and the context of the integer is undoubtly broken, thus corrupting the data. This would require testing, I know, but at this point, it seems more than a useless debate
However, the dumping operators << and >> might provide a better solution, like you have stated. I forgotted them first, thinking that they were only available when using serialization. But, yes, they should work very well, too. I believe they even check the type of source data so no corruption should occur.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti Keskinen wrote:
So, the function starts from the beginning address to copy data into the file on a byte-by-byte basis. It reads one byte of data, and writes it down. An integer is already 4 bytes long, so this won't pose a problem if the integer is in limit of 1 byte dimension
Are you saying that if an int has a vlaue of 128 to -127 it only occupies 1 byte?
An integer is always 4 bytes long regardless of its content. (in this C++/compiler implementation)
Roger Allen - Sonork 100.10016
Strong Sad:
Clever I am? Next to no one.
Undiscovered and soggy.
Look up. Look down. They're around.
Probably laughing. Still, bright, watery.
Listed among the top. Ten.
Nine. Late night. Early morn.
Early mourn. Now I sleep.
|
|
|
|
|
Basically, yes, though I might have presented it in an obscure manner.
An integer that is under the first 255 numbers from zero (0-255 or +128/-127) uses the last byte to designate it's value. All other bytes are zero. So, on writing this integer into a file, there will be three zero-bytes and one "data" byte.
Hence the saying "the integer is in limit of 1-byte dimension", meaning, that one byte is enough to represent the actual integer, though 4 bytes are always used, like you said.
Considering that an integer is "always" 4 bytes long in the memory (or in a file), it's representation in the file, whether it was one or more bytes long, should always show up correctly in memory as well, as memory-wise copying is done on byte-by-byte basis by the reading/writing functions. Or, this is how I have understood that they work..
This means that if the data becomes corrupted while doing this, there might be a compiler optimization command responsible that links the adjacent bytes to each other. Like, could it be that the 'size' optimization command decreases the memory requirement of an integer if it doesn't require all four bytes to represent itself ?
If the integer only requires two bytes to represent itself, the compiler, when executing with an optimization, actually caps the integer's length into two bytes ? I know this doesn't sound logical at all, but well, I'm quite outta ideas on why the data might get corrupted, as it does
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|