Click here to Skip to main content
16,005,552 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Preventing a file from copying.? Pin
Prakash Nadar3-Apr-04 2:29
Prakash Nadar3-Apr-04 2:29 
AnswerRe: Preventing a file from copying.? Pin
Alexander M.,4-Apr-04 1:08
Alexander M.,4-Apr-04 1:08 
QuestionSMTP Server? Pin
Timothy Grabrian2-Apr-04 18:08
professionalTimothy Grabrian2-Apr-04 18:08 
AnswerRe: SMTP Server? Pin
Prakash Nadar2-Apr-04 19:05
Prakash Nadar2-Apr-04 19:05 
AnswerRe: SMTP Server? Pin
Paul Ranson3-Apr-04 8:58
Paul Ranson3-Apr-04 8:58 
QuestionAnyone has any experience on using CHtmlEditCtrl? Pin
usfesco2-Apr-04 13:06
usfesco2-Apr-04 13:06 
QuestionRe: Anyone has any experience on using CHtmlEditCtrl? Pin
Debapritam Chakra29-Dec-16 4:05
Debapritam Chakra29-Dec-16 4:05 
GeneralCOnverting char to int and retaining value Pin
CNewbie2-Apr-04 12:50
CNewbie2-Apr-04 12:50 
The Below code was able to take 2 char's from an array stream and turn it into an integer # and Convert it to Decimal.

However, unless I am missing something here, what it fails to do is the other half of what my problem was, that I wanted to take those 2 chars from the array stream and just convert them to an int value and leave them be, not convert them to decimal. I tried to do it myself, but it wasn't coming out correct.

Thank You

<br />
#include <iostream><br />
#include <cstring><br />
using namespace std;<br />
<br />
int Convert(char a, char b);<br />
<br />
void main(){<br />
cout << "" << Convert('A', 'A') << endl;<br />
}<br />
<br />
int Convert(char a, char b){<br />
int intTemp, intVal = 0;<br />
char strBuffer[3];<br />
<br />
strBuffer[0] = a;<br />
strBuffer[1] = '\0';<br />
<br />
intTemp = atoi(strBuffer);<br />
<br />
if (intTemp != 0){<br />
intVal = intTemp << 4;<br />
}<br />
else{<br />
switch (toupper(a)){<br />
case 'A':<br />
intVal = intVal | 0xA0;<br />
break;<br />
case 'B':<br />
intVal = intVal | 0xB0;<br />
break;<br />
case 'C':<br />
intVal = intVal | 0xC0;<br />
break;<br />
case 'D':<br />
intVal = intVal | 0xD0;<br />
break;<br />
case 'E':<br />
intVal = intVal | 0xE0;<br />
break;<br />
case 'F':<br />
intVal = intVal | 0xF0;<br />
break;<br />
default:<br />
return 0;<br />
break;<br />
}<br />
}<br />
<br />
strBuffer[0] = b;<br />
strBuffer[1] = '\0';<br />
<br />
intTemp = atoi(strBuffer);<br />
<br />
if (intTemp != 0){<br />
intVal = intVal | intTemp;<br />
}<br />
else{<br />
switch (toupper(b)){<br />
case 'A':<br />
intVal = intVal | 0x0A;<br />
break;<br />
case 'B':<br />
intVal = intVal | 0x0B;<br />
break;<br />
case 'C':<br />
intVal = intVal | 0x0C;<br />
break;<br />
case 'D':<br />
intVal = intVal | 0x0D;<br />
break;<br />
case 'E':<br />
intVal = intVal | 0x0E;<br />
break;<br />
case 'F':<br />
intVal = intVal | 0x0F;<br />
break;<br />
default:<br />
return 0;<br />
break;<br />
}<br />
}<br />
<br />
return intVal;<br />
} <br />

GeneralRe: COnverting char to int and retaining value Pin
Michael Dunn2-Apr-04 13:58
sitebuilderMichael Dunn2-Apr-04 13:58 
GeneralRe: COnverting char to int and retaining value Pin
CNewbie2-Apr-04 18:56
CNewbie2-Apr-04 18:56 
GeneralRe: COnverting char to int and retaining value Pin
Johnny ²2-Apr-04 23:42
Johnny ²2-Apr-04 23:42 
GeneralRe: COnverting char to int and retaining value Pin
Pedro Ruiz2-Apr-04 23:50
Pedro Ruiz2-Apr-04 23:50 
GeneralRe: COnverting char to int and retaining value Pin
GflPower4-Apr-04 19:12
GflPower4-Apr-04 19:12 
GeneralCString::Format() Pin
Oriented2-Apr-04 12:33
Oriented2-Apr-04 12:33 
GeneralRe: CString::Format() Pin
Michael Dunn2-Apr-04 13:57
sitebuilderMichael Dunn2-Apr-04 13:57 
GeneralRe: CString::Format() Pin
gUrM33T2-Apr-04 15:25
gUrM33T2-Apr-04 15:25 
GeneralRe: CString::Format() Pin
Prakash Nadar2-Apr-04 16:19
Prakash Nadar2-Apr-04 16:19 
GeneralRe: CString::Format() Pin
Graham Bradshaw2-Apr-04 21:53
Graham Bradshaw2-Apr-04 21:53 
GeneralRe: CString::Format() Pin
Prakash Nadar3-Apr-04 2:27
Prakash Nadar3-Apr-04 2:27 
GeneralRe: CString::Format() Pin
Gary R. Wheeler3-Apr-04 2:55
Gary R. Wheeler3-Apr-04 2:55 
GeneralScroll Bar Pin
Oriented2-Apr-04 12:16
Oriented2-Apr-04 12:16 
GeneralRe: Scroll Bar Pin
gUrM33T2-Apr-04 15:33
gUrM33T2-Apr-04 15:33 
GeneralParse CHAR pointers Pin
gls2ro2-Apr-04 11:55
gls2ro2-Apr-04 11:55 
GeneralRe: Parse CHAR pointers Pin
John R. Shaw2-Apr-04 12:11
John R. Shaw2-Apr-04 12:11 
GeneralRe: Parse CHAR pointers Pin
gUrM33T2-Apr-04 15:28
gUrM33T2-Apr-04 15:28 

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.