|
toxcct wrote:
ssprintf(str, "0x%X", c);
Shouldn't that be:
sprintf(str, "%#X", c);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
for ssprintf -> sprintf, yes, i made a mistake
for 0x%X -> %#X, it is as you prefer...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi Dear,
Just do the following
byte _val;
char _data[4]="";
sscanf(_data,"%x",&_val);
Regards
~Kid
|
|
|
|
|
itkid wrote:
sscanf(_data,"%x",&_val);
Perhaps you meant sprintf() instead of sscanf() .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Sorry still not working, getting the following,
error C3861: 'sprintf': identifier not found, even with argument-dependent lookup
if I use sscanf, same error with obvious replacements.
|
|
|
|
|
The sprintf() function is part of stdio.h. I do not know if that set of APIs is available with VS.Net.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Can't seem to get it to work at all tbh. But eh, what do I know?
Surely .net must provide some way to format a string to dispay value in hex. Or you would think so!!
|
|
|
|
|
|
Christian Graus might have a few articles in this regard.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I'll give it a go.
Cheers everyone for the help!
|
|
|
|
|
Hi,
I have to create a CMap and store N number of (CString,int)
and i want to look up using CString and return value would be int.
If any body have gone through this requirement pls let me know.
i am new to CMap.If anyother method exist also welcome.
regards
Chezhian
|
|
|
|
|
<br />
#include <afxtempl.h><br />
<br />
CMap<CString, LPCTSTR, int, int> myMap;<br />
<br />
myMap.SetAt("one", 1);<br />
myMap.SetAt("two", 2);<br />
myMap.SetAt("three", 3);<br />
<br />
int nValue = 0;<br />
if (myMap.Lookup("two", nValue))<br />
{<br />
TRACE(_T("value is %d\n"), nValue);<br />
}<br />
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
hi,
I tried this.
It gives the following errors
'myMap':UnKnown size
'myMap':Cannot be destroyed
'CMap':no appropriate default constructor available
Is any header has to include for this.
I am using vc++ 7.1 version?
Regards
Chezhian
|
|
|
|
|
rgchezhian wrote:
Is any header has to include for this.
How about afxtempl.h .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
It doesn't give any change in error
|
|
|
|
|
I copied the code into 7.1 and it compiled fine.
I don't get those errors even if I don't include afxtempl.h. It almost sounds like you've created your own CMap class within the project. If so, that would be a problem.
Here's what I did to test the code:
1) File -> New -> VC++ Projects -> Win32 -> OK
2) Application Type = Console Application
3) Make sure Add support for MFC is checked
4) Finish
5) Add the #include <afxtempl.h> statement below stdafx.h
6) Add CMap code to _tmain
Compiles fine.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
i followed the same sequence and declared CMap variable.
CMap myMap;
But still it shows the following error
'myMap':UnKnown size
'myMap':Cannot be destroyed
'CMap':no appropriate default constructor available
'CMap' : use of class template requires template argument list
|
|
|
|
|
The map class is templated, so you need to declare the key and value types in the declaration.
CMap<CString, LPCTSTR, int, int> myMap;
-> maps string keys to integer values
CMap<BYTE, BYTE, void*, void*> myMap;
-> maps BYTE keys to void pointer values...
CMap<int, int, CPoint, CPoint> myMap;
-> maps int keys to CPoint values
etc.
More info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_MFC_CMap.asp
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
I forgot to format the angled brackets in my post, causing the #include statement to screw up.
David posted the correct #include
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
but i didn't inclucde #include
But it shows error
|
|
|
|
|
Could someone help me?
First, i use the GetVersionEx function get the OS information.
But for the window server 2003 and 64-bit XP professional,the dwMajorVersion are both 5, and dwMinorVersion are both 2, i found a code snippet at microsoft's website. It is show that :
switch (osvi.dwPlatformId)
{
// Test for the Windows NT product family.
case VER_PLATFORM_WIN32_NT:
// Test for the specific product.
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
printf ("Microsoft Windows Server 2003, ");
//you can view the whole code on
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/detecting_a_product_suite.asp[^]
//here judge the windows server 2003 through the flag VER_PLATFORM_WIN32_NT.
But i found that in 64-bit XP OS, the flag also is VER_PLATFORM_WIN32_NT.
So what should i do to judge the two OS? windows server 2003 and 64-bit XP OS.
>|Gaara|<: boku ha jiben shika aimasen.
|
|
|
|
|
Could someone help me? pls, or give me some tips?
>|Gaara|<: boku ha jiben shika aimasen.
|
|
|
|
|
Hello gurus,
Please be patient with a newbie.
Everywhere I look on the web I see code with these strange vriable types written in capitals like "DWORD" or "HANDLE". Pleople just declare them without having a class of type dword or handle. When I try to use such code, ofcourse the compiler says:
'DWORD' : undeclared identifier
I am trying to use a function called CreateFile which has the attributes:
HANDLE CreateFile(
LPCTSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDispostion,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
);
It return type is "HANDLE". What the? Theres no such thing. Is it an int?
MSDN says that "dwDesiredAcess" has to be either 0, GENERIC_READ or GENERIC_WRITE. Is GENERIC_READ a string or what?
When I try to use the the function. ie:
hComm = CreateFile(portname,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
0);
The compiler says:
'GENERIC_READ' : undeclared identifier.
Look, this is a basic question that has porbably been answered elsewhere? But what am I supposed to search for? "variable types written in CAPITALS"?
Pleas help.
|
|
|
|
|
DWORD is just a typedef for unsigned long:
typedef unsigned long DWORD;
HANDLE is just a typedef for void*
typedef void *HANDLE;
handle is a kind of pointer to the windows objects, like bitmaps, brush, etc.
http://www.priyank.in/
|
|
|
|
|
Priyank Bolia wrote:
HANDLE is just a typedef for void*
typedef void *HANDLE;
not always: see WINNT.H
|
|
|
|