|
Can anyone tell meho w to put a conversion constructor in this and implement it?
Matt
#include <iostream.h>
#include <string.h>
#define maxString 32000
class myString
{
int length;
char *stringData;
public:
myString();
myString(myString &);
int lengthof();
void show();
void getString();
};
myString::myString() // default constructor
{
length = 0;
stringData = new char[1];
}
myString::myString(myString &) //copy constructor
{}
void myString::getString()
{
char *firstString = new char[maxString];
cout << "Enter String: ";
cin.getline(firstString,maxString);
length = strlen(firstString);
stringData = new char[length];
for (int I=0;I
|
|
|
|
|
Not sure what you mean by a "conversion constructor". If you mean a copy constructor, then the prototype needs to be myString::myString( const myString& ) Note the parameter is a constant reference, your current code is missing the const.
--Mike--
http://home.inreach.com/mdunn/
your with and
|
|
|
|
|
Well, I was trying to display the date/time stamp (last modified) of a file using the following:
FILETIME ftTmp;
SYSTEMTIME stTmp;
GetFileTime( hFile, NULL, NULL, &ftTmp );
FileTimeToSystemTime( &ftTmp, &stTmp );
And I have noticed that the time I have derived was always 8 hours late. This is true to all the files I tried to read the info from. Am I doing something wrong here? Are there initializations needed? Is this a problem of MFC?
Any help/comment would be appreciated. Thanx!!!
Ryan V. - ryan@mobiling.nec.co.jp
----------------------------------
Discovery consists of looking at
the same thing as everyone else
and thinking something different.
----------------------------------
|
|
|
|
|
I was still looking around to solve my particular problem and I came across this function: FileTimeToLocalFileTime()
And added this to my code:
FILETIME ftTmp, ftLocal;
SYSTEMTIME stTmp;
GetFileTime( hFile, NULL, NULL, &ftTmp );
FileTimeToLocalFileTime( &ftTmp, &ftLocal );
FileTimeToSystemTime( &ftTmp, &stTmp );
This seems to solve my problem. The time returned by GetFileTime was UTC based and I still have to convert it to local time. This would account for the 8 hours discrepancy 'coz my current location is GMT+08:00.
Hehehe... I solved my own problem.
Ryan V. - ryan@mobiling.nec.co.jp
----------------------------------
Discovery consists of looking at
the same thing as everyone else
and thinking something different.
----------------------------------
|
|
|
|
|
http://www.codeproject.com/dialog/stackdialog.asp
A great example with exactley what I need in my program. One problem....how do I derive my dialogs to TStacked Dialog thingy?
Argh if someone can explain this to me and how to get this working in my app, please Id appreiciate it very very much!
Thanks
Ashley 'Ashman' Rowe
www.settlers.net
|
|
|
|
|
I'm not quiet sure what your problem is. Have you looked at the demo project with the article.
Create your dialog resource as normal, create a class for CDialog and then edit the code and replace CDialog with TStackedDialog and make the other changes the article describes.
hope this helps,
Michael
|
|
|
|
|
Thanks man! I will try that....Sounds so easy here I am thinkin there is an option to derive from a class LOL!!
Thanks again
Ashman
www.settlers.net
|
|
|
|
|
Hi,
It seems quite complicated to use tab controls. I tried many times to get it work, but without success...
Could someone briefly explain me how to get things working? What are the different steps?
Thanks very much for your help
|
|
|
|
|
I am in c++ class in 9th grade and I need to make a win32 concole app, that has 6 options 1 generates a random nubmer another tellis if it is greater then 25 and less then 100, the other function is it generates a random number and the other let's me enter as many number's as a like intell I enter zero and avearages those numbers not including 0, then whatever I chose to make as a function, then a quit option!!!!!!!! PLEASE HELP I HAVE NO IDEAD CAN SOMEONE please help me make a menu ETC Give me any ideas.
|
|
|
|
|
Do you have any books to help you, like textbooks ? This is a *very* basic question, do you have any ideas at all ? You really should start by writing some code and posting it so that we can provide some help for you to learn, as opposed to writing a very basic C++ program that you can hand in, and you'll be back here when your next assignment is due.
Clue 1: Look up cin and cout.
Clue 2: Look up switch or if/else ( which is how switch is implimented )
Clue 3: Look up rand/srand
That's all you need actually. Feel free to post your code, or snippets of it you have trouble with, and both myself and others will be glad to point you in the right direction.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hello,
I have a dialog type app and I have 2 timers on the app, one timer displays the current time, and the other is a count down timer.. The problem I am having is that the count down timer is not very accurate.. it looses a few seconds every 10 minutes.. Is there another function other than OnTimer() that I can use that is exact? If so can someone provide me with a little code so I have a idea on how to use it..
Here is a small sample of the OnTimer function I am using.. I doubt there is anything wrong with it...
void CTimerDlg::OnTimer(UINT nIDEvent)
{
switch (nIDEvent)
{
case IDC_STATIC_TIMER1:
m_timer1.DisplayCurrentTime();
break;
case IDC_STATIC_TIMER2:
iS --;
m_timer2.Display(iS,iM,iH,iD,(CString)m_strTimer2="%D:%H:%M:%S");
break;
}
CBitmapDialog::OnTimer(nIDEvent);
Thanks,
Rob
|
|
|
|
|
I don't know about its accuracy... but you may use GetTickCount().
Take the initial value, then use subsequent calls to have a relative time (in milliseconds).
Otherwise use the same method with CTime::GetCurrentTime() and CTimeSpan.
HTH,
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
OnTimer is not very accurate. If you want higher precision, use the multimedia timer (look at the MSDN for details). Actually, the best timer I know of is the queue timer, but this one works only with Win2k and up.
I vote pro drink
|
|
|
|
|
Thank you both for your postings.. I have looked up Multimedia Timer at MSDN and it looks like is the way to go.. I'm pretty new at programing, do you have any small samples of how to implement the code? If not, no big deal, I'll try to plug away at the examples Microsoft gives (some of the stuff looks greek to me)
Thanks again for your input!
Rob
|
|
|
|
|
If I have a video clip of unknown length (file size) and in either AVI, MP3, or some other format, what would be the best way to display and control these clips from a C++ application?
One idea I have is embedding an HTML control so that I can use a resident viewer (MS MediaPlayer, RealPlayer, QuickTime, ...) from an HTML control page. Does anyone know how to embed an HTML page into VC++ applications/dialogs? (If I go this route.)
Thanks.
Johnny
|
|
|
|
|
Directshow. If you #include <dshow.h> and link to Strmiids.lib Strmbasd.lib for debug and Strmiids.lib Strmbase.lib for release, you can play a video like this:
HRESULT hr;
IGraphBuilder *pGraph;
IMediaControl *pMediaControl;
IMediaEvent *pEvent;
IMediaSeeking * pSeek;
IVideoWindow * pWindow;
// Create the filter graph manager and query for interfaces.
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
pGraph->QueryInterface(IID_IMediaSeeking, (void **)&pSeek);
pGraph->QueryInterface(IID_IVideoWindow, (void **)&pWindow);
pGraph->RenderFile((bstr_t)lpszMovie, NULL);
pMediaControl->Run();
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
You have to open this file with any hexadecimal or binary editor and see to the first lines. Its an "euristic" method... If you know format you can link to your application need library (winmm, qtmlclient ...)
Best regards,
Oleg
|
|
|
|
|
hi , my problem is the following :
i need to generate random float values from -3.5 to +3.5
but the build in rand() function has only support for integers.
any piece of code would be fine, thanks a lot, andreas
|
|
|
|
|
Look up RAND_MAX. Do the math yourself (i.e. -RANDMAX/7.0-3.5). If that doesn't give you enough randmomness (in MSVC you only get 1/32k) perhaps some rand48 implementation?
|
|
|
|
|
it doesnt have to be very exact....
thanks for your answer
|
|
|
|
|
Hey guys
I have just about run out of ideasi have this piece of code below which is ment to copy one buffer to another.
void CMiscFunctions::CopyValueToBuffer(BYTE *pDataToCopy, BYTE *pBuffer, DWORD *dwLengthOfBuffer, DWORD dwSizeOfData)
{
DWORD i = *dwLengthOfBuffer;
DWORD y;
char sTest[10];
_ultoa(*dwLengthOfBuffer ,sTest, 10);
AfxMessageBox(sTest);
char sTest2[10];
_ultoa(i ,sTest2, 10);
AfxMessageBox(sTest2);
for(y = 0; y < dwSizeOfData; y++, i++)
{
pBuffer[i] = pDataToCopy[y];
if(y == 0x00000ED85)
{
AfxMessageBox("full");
break;
}
}
*dwLengthOfBuffer = i;
}
But it won't copy anything bigger then 59kb. I posted this before but didn't explain it very well basically it copies from pDataToCopy to pBuffer. i is the position to start copying data to in the pBuffer and y is 0 just to increment through the pDataToCopy buffer. I also put in an if statment to see what the largest value is before it crashes which is 0x00000ED85 in hex or 60805. Which seems like a very odd number to crash on to me.
Anyway all help is appreciated peter.
|
|
|
|
|
Are you using Win16? In that case you must use "huge" pointers.
Else, make sure that 1) The dest buffer can hold at least dwSizeOfData+(*dwLengthOfBuffer) bytes, 2) don't release this code.
I'd recommend you to look up e.g. memcpy.
|
|
|
|
|
At first sight there's nothing wrong with your code, objectionable as it is. You might want to check if you reserve space enough at pBuffer to copy past the boundary of 59 KB. Why don't you try something like
int main(void)
{
BYTE pDataToCopy [128*1024], pBuffer[128*1024];
DWORD dwLengthOfBuffer=0;
DWORD dwSizeOfData=sizeof(pDataToCopy);
CMiscFunctions::CopyValueToBuffer(
pDataToCopy,pBuffer,
&dwLengthOfBuffer,dwSizeOfData);
return 0;
} and see what happens?
Also, I suggest you take a look at standard functions for memory copying like memcpy and memmove which will outperform your handmade loop and take the pains of doing the job for you.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Cheers Guys
The reason i haven't used memcpy and memove is that earlier on i have a function that copys DWORDS to the beginning of the buffer and memove and memcpy overite this DWORDS see this (pBuffer) has lots of data taken from different places then it is all written into a buffer.
Also the size of the buffer is set me realloc() would this be causing the problems.
Peter
|
|
|
|
|
Good day,
Does anyone know how to request a read receipt through an smpt command like NOTIFY or RET or anything? I've been looking all over the internet but can't seem to find anything on it. I know how to do it programatically using MAPI and Outlook but I have an smtp wrapper class and want to use a straight code rather than using MAPI, etc. Any help is greatly appreciated.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|