|
Hey man, you haven't a Option3 in your union .
BTW: welcome back!
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I did say I wasn't by a compiler, and the reader should take my answer with a large dose of doubt. Lucky, eh...
I already had to edit it, because I had too many bits (9) to start with...
I've been lurking a while, but the questions were either already ably answered, or I couldn't think of anything polite to reply with. "You couldn't find your arse with elbows, Go get another career" isn't the most helpful answer, and a hint that I should avoid an answer. Don't want to be another Outlaw!
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
struct PacketHeader ph;
unsigned char firstbit = (ph.flags & 1);
unsigned char secondbit = ((ph.flags >> 1) & 1);
unsigned char thirdbit = ((ph.flags >> 2) & 1);
unsigned char fourthbit = ((ph.flags >> 3) & 1);
unsigned char remaining = (ph.flags >> 4);
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
what happens with if condition in following code?
int function(int i)
{
printf("inside function");
return 0;
}
int main()
{
if(function)
printf("hi");
else
printf("bye");
}
and output is only
hi
why compiler doesn't complaints about wrong function call?
modified on Thursday, July 23, 2009 12:08 PM
|
|
|
|
|
What is fun in your code? Is that suposed ot be:
if (function) ...
?
If so, then the answer is simple, in your if the address of the function will be checked against zero, and since it is not zero, it will come out as TRUE thus, you get "hi".
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
yes.. it's
if(function)
and thanx ..I got it.
|
|
|
|
|
Your function doesn't get called.
I think you mean:
if (function (1234))
...
But instead you're checking if the pointer to function is not 0, which it isn't, so it counts as true, so you get "hi".
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
In more detail, a procedural function name in C/C++ is a pointer to a function (a memory address). This is how you can pass one function to another function (like with the CRT qsort() function.) So in your if statement, you are checking whether function exists, which it does. To call a function, you have to use the parentheses syntax, i.e. function(1) .
|
|
|
|
|
hello,
i created 2 c++ applications, one is win32 and other is mfc. i want to restart the win32 process using mfc application. please tell me how to do this ??
also i want to run only 1 instance of process of both the processes. please suggest ??
btw thanks.
|
|
|
|
|
rahuljin wrote: i created 2 c++ applications, one is win32 and other is mfc. i want to restart the win32 process using mfc application. please tell me how to do this ??
also i want to run only 1 instance of process of both the processes. please suggest ??
killprocess and startexecute
|
|
|
|
|
please explain a bit. i can find good info about the killprocess.
|
|
|
|
|
1. CreateProcess[^] or ShellExecute[^]
2. Google is your friend, but look at this[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
createprocess() can start a process but cannot restart a running process.
|
|
|
|
|
Sorry, i thought by "restart" you meant that the process got killed/exited by someone else, for example by a user action and you wanted to restart it again.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I just replied to your yesterday's post. Ignore it. Answer me here: What *exactly* are you trying to achieve. Why restart a Win32 Process? Why use both Win32 and MFC? None of this makes sense to me.
We may probably be able to suggest you a much better way of doing it, but only if you explain what are you trying to do.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
sorry but i could not find my old question.
i created the win32 c++ application long back when i dont have any idea of mfc. it is working fine.
with mfc, i create a gui which accept the some content and save them in text files. these text files are then used by the win32 application. win32 application runs at startup of windows and it takes the information from the files and starts using it (it is socket application so it will not read the file again until it receives some information for the ip which is saved in the text file).
so i want to restart the win32 application when closing mfc application so that win32 application can use the updated text files.
actually i want to use TerminateProcess() and then start it with CreateProcess() function. but i read that TerminateProcess() can create problem with DLL structure.
|
|
|
|
|
How hard is it to add MFC support to the console application and send a message to it so that it reads the new file again in response to the message? I understand you are having a trouble communicating from your MFC app to the console app?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
the win32 application is not a console application. i dont know how to communication between the two application can be set.
in vs2008, i used win32 project (not win32 console application) for creating the win32 application. also the header files used are ---
#include <windows.h>
#include <winsock.h>
#include <tchar.h>
#include <wchar.h>
#include <iostream>
#include <fstream>
#include <shlwapi.h>
|
|
|
|
|
Does you application contain or create a window. If yes, you can use Window Messaging to communicate between two application, just add common message id between two application, and related function in WndProc function for win32 application and between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP for MFC application.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
there is no create window function in the win32 application. there is only messagebox().
modified on Friday, July 24, 2009 4:12 AM
|
|
|
|
|
You could send the win32 app a message and a message handler to it. There are several tutorials on IPC in CP, just take a look at those.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: How hard is it to add MFC support to the console application and send a message to it so that it reads the new file again in response to the message
Can't u send message to Win32 application ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Not if it is a console application.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: Not if it is a console application.
Humm... we can send window message to container window then
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Sorry if my comment hurt. That’s not intentional.. i think you felt bad.. my apology!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|