Click here to Skip to main content
15,921,454 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Shell_NotifyIcon problem.. Help Techies!! Pin
rohit.dhamija18-Sep-03 20:48
rohit.dhamija18-Sep-03 20:48 
GeneralAuto Run with FloppyDisk Pin
maharsoft17-Sep-03 17:27
maharsoft17-Sep-03 17:27 
GeneralRe: Auto Run with FloppyDisk Pin
Larry Antram17-Sep-03 18:15
Larry Antram17-Sep-03 18:15 
GeneralRe: Auto Run with FloppyDisk Pin
Alexander M.,18-Sep-03 6:23
Alexander M.,18-Sep-03 6:23 
GeneralSetWindowPlacement Doesn't display the Dialogbox properly Pin
vancouver77717-Sep-03 17:18
vancouver77717-Sep-03 17:18 
GeneralRe: SetWindowPlacement Doesn't display the Dialogbox properly Pin
Jagadeesh VN17-Sep-03 21:53
Jagadeesh VN17-Sep-03 21:53 
QuestionChar[1] to UINT ??? Pin
wow999917-Sep-03 16:03
wow999917-Sep-03 16:03 
AnswerRe: Char[1] to UINT ??? Pin
Terry O'Nolley17-Sep-03 17:11
Terry O'Nolley17-Sep-03 17:11 
When you define a variable as char[1] rather than just char:

char CharArray[1];
rather than
char SingleChar;

you have changed a lot!

Even though the array you defined has only 1 element (making it the same as a single char memory usage-wise), it is referenced the same way as if you had defined it as char[1000] - ie as the memory address of its first (zero-eth) element.

Since the value of CharArray is a memory address (in other words CharArray is a pointer), it is not compatible for direct assignment to an UINT.

So, to convert a char[1] to an UINT you need to specify which element of the array you are talking about. In the case of an array of chars with 1 element, the only valid reference is the zeroeth element - CharArray[0].

Whenever you assign a variable that has a data type that is different from the one you are assigning it to, you need to cast it. "Cast" just means that you are basically telling the compiler "Thanks for the warnings, but I know what I'm doing. I know they were defined as different types, but I really want to do this, so butt out!". Casting will only work if the 2 data types are compatible. Since an UINT is large enough to hold the largest possible char and both data types are non-abstract, the types are compatible and your casting will succeed:

<br />
char CharArray[1];  // has only 1 valid element - referenced as CharArray[0]<br />
char SingleChar;<br />
UINT x;<br />
<br />
// to assign a value to this array you must reference which element you are assigning<br />
CharArray[0] = 'A'; <br />
// since this is a char and not an array you can assign it directly                     <br />
SingleChar = 'A';   <br />
<br />
// Just cast the assignment by placing the data type you are casting (converting it to) in parentheses before the assignment.<br />
x = (UINT)SingleChar;  <br />
                      <br />
x = (UINT)C[0];        <br />









GeneralRe: Char[1] to UINT ??? Pin
wow999917-Sep-03 19:09
wow999917-Sep-03 19:09 
GeneralRe: Char[1] to UINT ??? Pin
jhwurmbach17-Sep-03 22:57
jhwurmbach17-Sep-03 22:57 
GeneralRe: Char[1] to UINT ??? Pin
Terry O'Nolley18-Sep-03 12:27
Terry O'Nolley18-Sep-03 12:27 
QuestionBitmap from data??? Pin
IceBerG7117-Sep-03 16:01
IceBerG7117-Sep-03 16:01 
GeneralNeed help with Tic-Tac-Toe Pin
Snyp17-Sep-03 14:34
Snyp17-Sep-03 14:34 
GeneralRe: Need help with Tic-Tac-Toe Pin
Terry O'Nolley17-Sep-03 16:43
Terry O'Nolley17-Sep-03 16:43 
GeneralRe: Need help with Tic-Tac-Toe Pin
Snyp17-Sep-03 16:46
Snyp17-Sep-03 16:46 
GeneralDLLs and XP themes... Pin
LukeV17-Sep-03 14:25
LukeV17-Sep-03 14:25 
GeneralRe: DLLs and XP themes... Pin
Alexander M.,18-Sep-03 6:25
Alexander M.,18-Sep-03 6:25 
GeneralJPG width and height Pin
alex.barylski17-Sep-03 14:19
alex.barylski17-Sep-03 14:19 
GeneralRe: JPG width and height Pin
JWood18-Sep-03 12:20
JWood18-Sep-03 12:20 
GeneralRe: JPG width and height Pin
alex.barylski18-Sep-03 15:38
alex.barylski18-Sep-03 15:38 
GeneralProblems moving to .NET studio Pin
Tom Wright17-Sep-03 12:24
Tom Wright17-Sep-03 12:24 
GeneralRe: Problems moving to .NET studio Pin
valikac17-Sep-03 12:42
valikac17-Sep-03 12:42 
GeneralRe: Problems moving to .NET studio Pin
Tom Wright17-Sep-03 17:06
Tom Wright17-Sep-03 17:06 
GeneralRe: Problems moving to .NET studio Pin
Steve S18-Sep-03 1:47
Steve S18-Sep-03 1:47 
GeneralRe: Problems moving to .NET studio Pin
Alexander M.,18-Sep-03 6:21
Alexander M.,18-Sep-03 6:21 

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.