|
Hello Iain,
Thanks for replying.
Actually this have a documentation. I have to write the body of this function. This function exists in a DLL. I don't have to think outside code of the DLL. Sombody just call my function.
Pls reply
|
|
|
|
|
Shaheen.India wrote: void fn_VersionInfo(const char** EngineVersionInfo)
{
}
void fn_VersionInfo(const char** EngineVersionInfo)
{
*EngineVersionInfo = "00.00.00.00";
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello CPallini
Thanks it works fine
|
|
|
|
|
It is a good idea to pass in a second size_t parameter which specifies the size of the memory allocated for the string. Otherwise it could lead to a buffer overrun.
And if you want to use real C++ style do this -
void fn_VersionInfo(const char*& EngineVersionInfo, size_t size)
{
strcpy_s(EngineVersionInfo, size, "version string");
}
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|
|
Hello!
Could anyone, please, forward me the right direction to do HEX->BIN->DEC conversions with 40 bit variable.
The point:
I have a CEdit type input on a dialog and a CComboBox to select data type. The user can choose to input data in HEX, DEC, BIN, formats the data length can be up to 40 bits (I use a char[5] type variable to store data in BIN). I have already made functions for getting user input from HEX and BIN (below):
<br />
void FillBuffer(void)<br />
{<br />
CString str;<br />
<br />
char Bit = 0;<br />
char Byte = 0;<br />
char Mask = 0;<br />
char Buf = '0';<br />
<br />
<br />
m_CardNumber.GetWindowTextA(str);<br />
str.MakeUpper();<br />
<br />
for(int i = 0;i<sizeof(Card.Data);i++)<br />
{<br />
Card.Data[i] = 0x00;
}<br />
<br />
int MaxLength;<br />
<br />
switch(PrevFormat)<br />
{<br />
case HEX:
{<br />
MaxLength = 10;<br />
<br />
if(str.GetLength() < 10)<br />
MaxLength = str.GetLength();<br />
<br />
for(int i = 0;<MaxLength;i++)<br />
{<br />
switch(str.GetAt(i))<br />
{<br />
case '0':<br />
Mask = 0;<br />
break;<br />
case '1':<br />
Mask = 1;<br />
break;<br />
case '2':<br />
Mask = 2;<br />
break;<br />
case '3':<br />
Mask = 3;<br />
break;<br />
case '4':<br />
Mask = 4;<br />
break;<br />
case '5':<br />
Mask = 5;<br />
break;<br />
case '6':<br />
Mask = 6;<br />
break;<br />
case '7':<br />
Mask = 7;<br />
break;<br />
case '8':<br />
Mask = 8;<br />
break;<br />
case '9':<br />
Mask = 9;<br />
break;<br />
case 'A':<br />
Mask = 10;<br />
break;<br />
case 'B':<br />
Mask = 11;<br />
break;<br />
case 'C':<br />
Mask = 12;<br />
break;<br />
case 'D':<br />
Mask = 13;<br />
break;<br />
case 'E':<br />
Mask = 14;<br />
break;<br />
case 'F':<br />
Mask = 15;<br />
break;<br />
};<br />
if(Bit%2 == 0 || Bit == 0)<br />
{<br />
Mask = Mask << 4;<br />
}<br />
<br />
Card.Data[Byte] = Card.Data[Byte]|Mask;<br />
<br />
Bit++;<br />
<br />
if(Bit%2 == 0)<br />
{<br />
Byte++;<br />
}<br />
<br />
<br />
}<br />
break;
}<br />
case BIN:
{<br />
MaxLength = 40;<br />
<br />
if(str.GetLength() < 40)<br />
MaxLength = str.GetLength();<br />
<br />
for(int i = 0;i<MaxLength;i++)<br />
{<br />
Buf = str.GetAt(i);<br />
Bit++;<br />
<br />
if(Buf == '1')<br />
{<br />
Mask = 1;<br />
Mask = Mask << ((Bit % 8 > 0) ? ( 8 - (Bit % 8) ) : 0);<br />
Card.Data[Byte] = Card.Data[Byte] | Mask;<br />
}<br />
<br />
if(Bit%8 == 0)<br />
{<br />
Byte++;<br />
}<br />
}<br />
break;
}<br />
case DEC:<br />
{<br />
<br />
<br />
break;
}<br />
default:<br />
break;<br />
<br />
};<br />
<br />
<br />
}<br />
<br />
All this works fine, but, how to handle Dec to bin in my case?
Thanks
|
|
|
|
|
I would use strtol (well, its longer cousin...) for it all:
BOOL fillArray(LPCSTR s, int base, unsigned char data[5])
{
const unsigned __int64 GUARD = 1099511627776LL;
char * pcStop;
unsigned __int64 n = _strtoui64(s, &pcStop, base);
if ( n < GUARD )
{
unsigned char * p = (unsigned char *)(&n) + 4;
for (int i=0; i<5; i++)
{
data[i] = *p;
p--;
}
return TRUE;
}
else
return FALSE;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All,
I want to use PosstThreadMessage() function and i want to check if the thread handle is available before that, because sometimes the thread will be created and some times the the thread might not be created ...
So if the thread is not created i want the condition to fail ...
ex:
if( handle available)
{
ThreadPtr->PosstThreadMessage(MyMessage);
}
So can you tell me how to verify this .
Thanks..
Hari
|
|
|
|
|
And what happens when the thread finishes between checking for calling the CheckThreadAvailability and PostThreadMessage functions?
By it's nature such a function would be useless.
I think you need to go back to your more basic design to address this issue, rather than papering over the cracks.
With multithreading, you have to imagine that you are on a multi code spiteful processor. Anything bad that could possibly happen, will.
Keep track of the thread handles. Even when a thread finishes, the handle is still valid - you need to close it with CloseHandle too. (I think MFC will do that for you, but I don't touch MFC threading with a bargepole. I use Win32 exclusively - better documented).
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
You may use (with caveats suggested by the "Warrior Programmer") GetExitCodeThread function [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi,
I have to convert pdf file to tif file using C .would anyone help me providing source code .regards
Bill
|
|
|
|
|
No-one is going to give you a few lines of code to do this.
As you don't already realise this, you have a lot of learning / work ahead of you.
You need to find / pay for a pdf library that can render a PDF into a HDC.
Capture that HDC (which could be very large) into a bitmap.
Convert that bitmap into a tiff.
What about multipages? Maybe your pdf library can "print" one page at a time?
I hope that helps you with your google search terms. I know there are articles on CP for bitmap to tiff. And for simple PDF rendering.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
you can provide me code in c# also
|
|
|
|
|
Do you understand "gimme codez" doesn't work here, don't you?
Anyway, you may try: "gimme codez urgentz plz plz" or "gimme codez ASAP".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
billcodes wrote: you can provide me code in c# also
That's extremely kind of you. My answer before was not dependent on language.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
I can haz cheeseburger?
Visual Studio is an excellent GUIIDE.
|
|
|
|
|
> As you don't already realise this, you have a lot of learning / work ahead of you.
>You need to find / pay for a pdf library that can render a PDF into a HDC.
Is it a joke ?
You should learn Win32 api, GDI+, and COM : ~25 lines of code...
|
|
|
|
|
If you are going to sledge people, you might at least take the time and trouble to sledge the right person.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
<br />
<br />
#include "stdafx.h"<br />
#include <iostream><br />
using namespace std;<br />
<br />
<br />
void copy_array(char from[], char to[])<br />
{<br />
int i = 0;<br />
while(from[i] != '\0')<br />
{<br />
to[i] = from[i];<br />
i++; <br />
}<br />
to[i] = '\0';<br />
}<br />
<br />
<br />
void copy_pointer(char *from, char *to)<br />
{<br />
while((*to++ = *from++) != '\0');<br />
}<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
char *from = "c plus plus";<br />
char *to = "oooooooooooooooo";<br />
copy_pointer(from, to);
<br />
cout << to << endl;<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
Any idea what's the problem in the following code?
int main()
{
char* str = "Hello";
str[0] = 'Y';
cout<<str;
return 0;
}
|
|
|
|
|
theCPkid wrote: Any idea what's the problem in the following code?
Apart from the fact that it will print "Yello" , nothing.
|
|
|
|
|
have you really tried it? i have the feeling that you will get write access error...
|
|
|
|
|
theCPkid wrote: i have the feeling that you will get write access error...
Yes, you're right; my apologies.
|
|
|
|
|
Loveprogramer wrote: char *from = "c plus plus";
char *to = "oooooooooooooooo";
Here "from" and "to" are constant strings exactly, so the codes below would be mistake.
"*to++ = *from++".
If you declare "from" and "to" as array of string, your program would work fine.
Just like:
char from[] = "c plus cplus";
char to[] = "oooooooooooooooooooooo";
|
|
|
|
|
carter2000 wrote: Here "from" and "to" are constant strings exactly, so the codes below would be mistake.
Not true; declaring a string as char* str or char str[] yields the same result.
|
|
|
|
|
Maybe I made something wrong, but it just works fine in my computer. My compiler is VS2008.
|
|
|
|