|
modify like this..
main()
{
int *hello = new int;
printf("Hi, Enter any value > ");
scanf("%d",hello);
switch (*hello)
{
case 1: printf("your 1 luck number is > %d\n",hello);
case 2: printf("your 2 luck number is > %d\n",hello);
case 3: printf("your 3 luck number is > %d\n",hello);
default: printf("your 4 luck number is > %d\n",hello);
}
}
nave
|
|
|
|
|
If you need a pointer to hello, you can get one by writing &hello .
|
|
|
|
|
moloza wrote: int *hello;printf("Hi, Enter any value > ");scanf("%d",&hello);switch (hello)
if you still want to use pointers in your code, you see this example
#include<stdio.h>
#include <malloc.h>
main()
{
int *hello;
printf("Hi, Enter any value > ");
hello=(int*)malloc(sizeof(int));
scanf("%d",hello);
switch (*hello)
{
case 1: printf("your 1 luck number is > %d\n",*hello); break;
case 2: printf("your 2 luck number is > %d\n",*hello);break;
case 3: printf("your 3 luck number is > %d\n",*hello);break;
default: printf("your 4 luck number is > %d\n",*hello);
}
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks for ALL
ITS working now>>
CHEERS
Ajmi
|
|
|
|
|
moloza wrote: ITS working now>>
you are always welcome!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
I have an application residing on a server that multiple users can run from their own PC's. I would like any one instance of the application to be able to notify all other instances that a data file has been updated, ideally, providing information regarding the record that has changed.
I cant use a client/server approach as the server is (for us anyway) simply storage space, I cant run applications on there.
Im not sure if a Mutex would work here as each person is running the app in their own address space. TCP/IP messages might work but with dynamic IP addresses, this might prove difficult.
Anyone have any suggestions? I could be missing the obvoius here!
TIA
Tony
|
|
|
|
|
Sounds like you need what is called "true peer to peer" networking. The key would be how to handle discovery. I have no idea how true p2p does that.
What they call p2p hybrid networks use servers to assist in the discovery process. This does not appear to be an option for you.
Perhaps using UDP for discovery is possible.
If you have a firewall in the network that only allows port 80 then I think you are hosed.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
You could play with file locking.
Lock various regions of a file on that server -- to denote things.
Personally, I prefer the tcp-ip method. It may be a little work to get going, but it's the richest solution.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
Since the application binary resides on a server you could place a COM object on the same server to manage updates. The application would still run on the client but all running instances would communicate (using DCOM) with an update component which runs on the server. The update component would inform its clients of changes using connection points.
Steve
|
|
|
|
|
Hi,
Thanks for the reply. I had also considered DCOM but as I understood it, this wouls still need a 'server application' to be running on the server. I was also put off DCOM because of its problems with NAT with remote access which, no doubt someone will want to do at some stage.
I would be very interested in your comments.
Thanks
Tony
|
|
|
|
|
is there a #define or something i can do to set a double to infinty without doing much math, or any?
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
|
The max value of a double is well below infinity.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Computers would no longer need people if they could handle infinite numbers.
And I doubt people would need computers if we could handle them ourselves.
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
The easiest way is to perform a divide by 0 with floating point exceptions disabled - 1.0 / 0.0 will do the trick. However, note that most of the math functions don't work with infinite numbers. You can disable floating point exceptions using _controlfp() .
Obviously, use -1.0 / 0.0 if you want -ve infinity.
BTW, you can represent infinity with a float or a double, despite what others have said... See here[^]
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
There are some defines in float.h that might be of use: DBL_MAX, FLT_MAX, etc.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I have a variable (CString) Username which has a username.
And a variable (Byte) m_type.
If Username starts and ends with _ (f.ex _John_)
then m_type = 0 (emploee)
Else m_type = 1 (client)
How i type these in C++ MFC code ?
|
|
|
|
|
see CString's Length and GetAt member functions.
if (str.GetAt(0)=='_') ... etc. use Length to make sure you don't try to GetAt a character that's past the end of the string.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
there is a way Getat(0) =="_" (from left)
GetAt(0)=="_" (from right) ? (so dont need to use length
|
|
|
|
|
yes, there is. it's called "Right"
but you still need to know how long the string is, because GetAt, Left, Right and Mid will all fail if you try to get characters past the end of the string.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
oh i got ur point, thanks very much
|
|
|
|
|
Hi Can some one please explain me the following...not the MSDN defination please
STDMETHODCALLTYPE
__export
__declspec
-- modified at 14:25 Wednesday 17th May, 2006
|
|
|
|
|
koumodaki wrote: STDMETHODCALLTYPE
If you are even remotely familar with the preprocessor, this should explain it:
#ifdef _WIN32 // Win32 doesn't support __export
#define STDMETHODCALLTYPE __stdcall
#else
#define STDMETHODCALLTYPE __export __stdcall
#endif
koumodaki wrote: __export
__declspec(dllexport) allows you to export functions, data and objects.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
in the easiest way ?
Using c++.
thank you.
-- modified at 12:50 Wednesday 17th May, 2006
|
|
|
|
|
<br />
uint32_t value; <br />
int i; <br />
uint8_t *cptr = (uint8_t *)&value; <br />
<br />
<br />
<br />
<br />
<br />
for (i = 0; i < sizeof(uint32_t); i++) <br />
cptr[i] = i + 1; <br />
<br />
<br />
<br />
<br />
<br />
switch (value) { <br />
case 0x01020304: <br />
printf("32 bit int is big-endian\n"); <br />
break; <br />
<br />
<br />
case 0x04030201: <br />
printf("32 bit int is little-endian about 8 bits\n"); <br />
break; <br />
<br />
<br />
case 0x03040102: <br />
printf("32 bit int is little-endian about 16 bits\n"); <br />
break; <br />
<br />
<br />
default: <br />
printf("I don't understand the result\n"); <br />
break; <br />
} <br />
google[^]
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|