|
Hello..
I want to do NOT operation..but i here output is wrong..
<br />
main()<br />
{<br />
unsigned int Value=4; <br />
<br />
Value = ~ Value; <br />
<br />
}<br />
but my output is 4294967291 insted of 251.
Please help me out..
Thanks
Shah
|
|
|
|
|
If you only want to use 8 bits, you need to use unsigned char . Int is 32 bit longs, so you get FFFFFFFB when you do the NOT operation.
udy
|
|
|
|
|
Shah Satish wrote: unsigned int Value=4; /* 4 = 0000 0100 */
Actually:
unsigned int Value = 4;
Value = ~Value;
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Actually The output (4294967291 = 0xFFFFFFFB) is correct (your assumptions are wrong) because the unsigned int type is 4-bytes wide:
HEX: ~0x00000004 =
0xFFFFFFFB
BINARY: ~0000 0000 0000 0000 0000 0000 0000 0100 =
1111 1111 1111 1111 1111 1111 1111 1011
if you want to obtain 251 then use the unsigned char type:
unsigned char Value;
Value = 4;
Value = ~ Value;
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.
|
|
|
|
|
not very sure abt this.. bt i guess that if u wanna arrive at 251 ie. -5 (sign extended), u gotta use short int or int instead of unsigned int.
hope this helps
|
|
|
|
|
Shah Satish wrote: /* 4 = 0000 0100 */
This is wrong. An integer is coded on 4 bytes, not on 1 byte, so it is 00000000 00000000 00000000 00000100 instead. Try to invert it, and you'll see that you will get 4294967291.
Replace the unsigned int by an unsigned char if you want to work on 1 byte.
|
|
|
|
|
Hi,
You are using unsigned int it is 32 bits long for 32 bit processer, and or depending on your compiler.
hence ~value is 0xFFFFFFFB not 0x000000FB,
if you really want 8bits of data use unsigned char instead.
Best Regards
Raj
|
|
|
|
|
Hello all
i have problem that when i'm input a character in emp_no field the program end or exit
i want that when i input number the program accept it and when i input character display me message that is wrong input and return to input number again
i used isdigit function but i want to return input again if the input not number
and Thank's For All
<br />
<br />
class EMPLOYEE <br />
{<br />
private:<br />
int emp_no;<br />
char emp_name[30];<br />
int age;<br />
int selary;<br />
int taxt;<br />
<br />
public:
void set_emp_no(int no)<br />
{<br />
<br />
emp_no=no;<br />
<br />
<br />
}<br />
<br />
int get_emp_no()<br />
{<br />
return emp_no;<br />
}<br />
<br />
void set_emp_name()<br />
{<br />
cin>>emp_name;<br />
}<br />
<br />
void get_emp_name()<br />
{<br />
cout<<emp_name;<br />
}<br />
<br />
void Set_emp ();<br />
<br />
};<br />
<br />
void EMPLOYEE::set_e()<br />
{<br />
int no,ag,sel;<br />
<br />
Begin:<br />
cout <<"\nEnter Employee No:";<br />
cin>>no;<br />
if (isdigit (no))<br />
set_emp_no(no);<br />
else<br />
{<br />
if (isalpha (no))<br />
cout <<"error man";<br />
}<br />
goto Begin;<br />
<br />
<br />
cout <<"\nEnter Employee Name:";<br />
set_emp_name();<br />
}<br />
To Be Or Not To Be
(KARFER)
|
|
|
|
|
goto Begin;
And You think you get away with that? You can make this a
while(1) {
...
} loop.
if( isdigit( no)) could be changed to
if( <code>!</code>isdigit( no)) {
...complain about error here...
} and the isalpha could subsequently be dropped.
Failure is not an option - it's built right in.
|
|
|
|
|
The variable no needs to be changed to a string or a char[] . Then you can loop through each character to determine if it is a digit or not.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hey guys, im taking some old code from my company and trying to make a library since the origional was about 20,000 lines of code with GIANT switch statement in each method.
any how, ive checked MSDN, and no one here(the 3 developers for release software are 23, 24, and 22, all straight out of college)
so the statements:
BOOL APIENTRY DllMain( HINSTANCE hModule, <br />
DWORD ul_reason_for_call, <br />
LPVOID lpReserved<br />
)<br />
{<br />
switch (ul_reason_for_call)<br />
{<br />
case DLL_PROCESS_ATTACH:<br />
case DLL_THREAD_ATTACH:<br />
case DLL_THREAD_DETACH:<br />
case DLL_PROCESS_DETACH:<br />
CGeneratePrinterCommands::_CGeneratePrinterCommandsHandle = hModule;<br />
break;<br />
}<br />
return TRUE;<br />
}<br />
<br />
temp = LoadResource(_CGeneratePrinterCommandsHandle, FindResource(_CGeneratePrinterCommandsHandle, MAKEINTRESOURCE(IDR_R800_XFER_M), _TEXT("HEXSTRING")));
cam anyone explain whats going on here regarding the _CGeneratePrinterCommandsHandle?
------------------------------
I win because I have the most fun in life...
|
|
|
|
|
Hi,
_CGeneratePrinterCommandsHandle is storing the hModule,
which is the handle to the instance of the dll file, it contains
some resource data of type HEXSTRING and id IDR_R800_XFER_M.
The resource data is fetched to the global memory temp.
Best Regards
Raj
|
|
|
|
|
thanks alot man, sorry i didnt back to you, i had an emergency and had to leave immediately
------------------------------
I win because I have the most fun in life...
|
|
|
|
|
For my job I have designed a particular scripting language, that's ok, and it works fine.
But now I want to make a program to help write these scripts, so I thought in a SDI application with a RichEditView, and I want to add some intellisense features, like any program enviroment you can find these days, so my question is simple.
Could you someone point me, maybe, an article or something like that that talk about this kind of feature?.
I don't know if I have explained well, I would like my program be able to show ie a list with the script keywords while someone is writing. How could I do that?.
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
pls check out these links.may be helpfull.
http://www.codeproject.com/useritems/JGIntelli.asp
http://msdn2.microsoft.com/en-us/library/zbcxy25t(VS.80).aspx
|
|
|
|
|
Ok, thank you, bigphish
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
hello when i run the debug version of .exe program works fine
when i run Release version of .exe then my program crash
complier shows me that it havnt found symbols in many .dll
i have tried the 2 steps of Keith's Rule guide
(
Last Resorts
Debugging in Release Mode
and
Making Debug Mode more like Release Mode
}
althought could fix it (or better didnt know where to look to fix the problem)
if i run the Release mode via MVSC++ 6.0 it works fine but if i run direcly for the Release.exe it crash
|
|
|
|
|
|
|
|
Hi all:
Yesterday I asked about dialog UI paint problem in which when the dialog overlapped with another window the dialog's UI got different kinds of trailing white strips. Today the problem solved accidentally in which DefWindowProc didn't get called once I finishing paint the dialog customarily, the modification was just a simple substitution from "break" to "return 1". For a hindsight, I know the rough idea behind this, I should have handled the painting by myself solely instead of let system handle it again, but I don't know what DefWindowProc done when I've painted the dialog made the dialog graffitified.
|
|
|
|
|
"The DefWindowProc function validates the update region. The function may also send the
WM_NCPAINT message to the window procedure if the window frame must be painted and send the
WM_ERASEBKGND message if the window background must be erased."
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all, I'm learning how to print in MFC and I know MFC will generate a 'printpreview' view for you once you've got all the printing settings right. I'm trying to find out how to make this 'PrintPreview' the initial view of an application so that when you enter the program with some initial parameters you get a 'PrintPreview' window directly before any operations. Has anyone got any ideas on this? Thanks in advance.
|
|
|
|
|
Hai,
I am new to dll.I have created a menu in my dll.i want to use that in other for a Dialog Based Appication. How I can acheive this
-- modified at 7:01 Wednesday 6th June, 2007
|
|
|
|
|
Go to Resource view. Right Click, Add Resource, Then Add Menu.
Customize the menu and call it whereever you want to use.
Programming in Dll is almost same as that of other application.
Anurag Gandhi.
|
|
|
|