Click here to Skip to main content
15,889,595 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Get List of Devices Currently Attached in a thread Pin
David Crow13-Oct-09 2:54
David Crow13-Oct-09 2:54 
QuestionInitialize into const char** Pin
m_mun11-Oct-09 23:15
m_mun11-Oct-09 23:15 
AnswerRe: Initialize into const char** Pin
Iain Clarke, Warrior Programmer11-Oct-09 23:20
Iain Clarke, Warrior Programmer11-Oct-09 23:20 
GeneralRe: Initialize into const char** Pin
m_mun11-Oct-09 23:43
m_mun11-Oct-09 23:43 
AnswerRe: Initialize into const char** Pin
CPallini12-Oct-09 0:08
mveCPallini12-Oct-09 0:08 
GeneralRe: Initialize into const char** Pin
m_mun12-Oct-09 0:32
m_mun12-Oct-09 0:32 
AnswerRe: Initialize into const char** Pin
«_Superman_»12-Oct-09 8:58
professional«_Superman_»12-Oct-09 8:58 
Question40 bit decimal to binary Pin
Makakuin11-Oct-09 21:03
Makakuin11-Oct-09 21:03 
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; //make sure to clear buffer..<br />
	}<br />
<br />
	int MaxLength;<br />
<br />
	switch(PrevFormat)<br />
	{<br />
		case HEX: //Read in hex store in binary<br />
			{<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; //Break HEX				<br />
			}<br />
		case BIN: // read binary string, store in binary buffer<br />
			{<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; //Break BIN<br />
			}<br />
		case DEC:<br />
			{<br />
<br />
				//How to handle this?<br />
<br />
				break; //Break DEC<br />
			}<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
AnswerRe: 40 bit decimal to binary Pin
CPallini11-Oct-09 22:19
mveCPallini11-Oct-09 22:19 
Questionhow to check if a thread handle is available Pin
Hari_1611-Oct-09 19:49
Hari_1611-Oct-09 19:49 
AnswerRe: how to check if a thread handle is available Pin
Iain Clarke, Warrior Programmer11-Oct-09 20:47
Iain Clarke, Warrior Programmer11-Oct-09 20:47 
AnswerRe: how to check if a thread handle is available Pin
CPallini11-Oct-09 22:21
mveCPallini11-Oct-09 22:21 
Questionconvert pdf to tif file in C Pin
billcodes11-Oct-09 18:49
billcodes11-Oct-09 18:49 
AnswerRe: convert pdf to tif file in C Pin
Iain Clarke, Warrior Programmer11-Oct-09 20:55
Iain Clarke, Warrior Programmer11-Oct-09 20:55 
GeneralRe: convert pdf to tif file in C Pin
billcodes11-Oct-09 22:08
billcodes11-Oct-09 22:08 
QuestionRe: convert pdf to tif file in C Pin
CPallini11-Oct-09 22:24
mveCPallini11-Oct-09 22:24 
GeneralRe: convert pdf to tif file in C Pin
Iain Clarke, Warrior Programmer11-Oct-09 22:45
Iain Clarke, Warrior Programmer11-Oct-09 22:45 
GeneralRe: convert pdf to tif file in C Pin
AspDotNetDev15-Oct-09 15:30
protectorAspDotNetDev15-Oct-09 15:30 
GeneralRe: convert pdf to tif file in C Pin
kilt13-Oct-09 2:23
kilt13-Oct-09 2:23 
GeneralRe: convert pdf to tif file in C Pin
Henry Minute13-Oct-09 5:23
Henry Minute13-Oct-09 5:23 
QuestionI want to copy strings,but occur this....."Access to memory errors....",why? Pin
milestanley11-Oct-09 17:32
milestanley11-Oct-09 17:32 
AnswerRe: I want to copy strings,but occur this....."Access to memory errors....",why? Pin
theCPkid11-Oct-09 18:24
theCPkid11-Oct-09 18:24 
GeneralRe: I want to copy strings,but occur this....."Access to memory errors....",why? Pin
Richard MacCutchan11-Oct-09 22:40
mveRichard MacCutchan11-Oct-09 22:40 
GeneralRe: I want to copy strings,but occur this....."Access to memory errors....",why? Pin
theCPkid11-Oct-09 22:59
theCPkid11-Oct-09 22:59 
GeneralRe: I want to copy strings,but occur this....."Access to memory errors....",why? Pin
Richard MacCutchan11-Oct-09 23:40
mveRichard MacCutchan11-Oct-09 23:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.