|
can n e one tell me how can i display any variable value or calulation result on the screen in form of message box or sort of like this....i m working in dialog base MFC application.
thanks.
|
|
|
|
|
Convert it to a string and display it. You might use CString::Format() , as you say you're using MFC.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Convert the result into a string using CString::Format .
The use the CString variable as the lpszText parameter of MessageBox .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Something like this ....
CString strTime;
strTime.Format("Time = %d", nMyTime);
AfxMessageBox(strTime);
.... Hope that helps
Ali
|
|
|
|
|
You may use CString::Format method [^] and then, for instance, AfxMessageBox function [^].
[added]
I'm a bit slow this morning...
[/added]
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]
|
|
|
|
|
CPallini wrote: I'm a bit slow this morning... Roll eyes
*Rajesh feeds the monkeys with genetically modified, steroid injected bananas*
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: *Rajesh feeds the monkeys with genetically modified, steroid injected bananas*
Slurp! May Carlo join Rajesh's monkey team?
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 guess gethostbyname("localhost") may help.
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]
|
|
|
|
|
Thanks for your reply.
I do not want to resolve the loopback address through naming services such as /etc/hosts file. I need to get the real loopback address configured with the machine irrespective of whether it is specified in /etc/hosts file or not. gethostbyname() will give me what is configured in /etc/hosts file.
Is there any other mechanism to get the real loopback address of the machine e.g. reading the routing table etc.?
Thanks and Best regards.
Gajendra Sharma
Gajendra
|
|
|
|
|
Gajendra Sharma wrote: I do not want to resolve the loopback address through naming services such as /etc/hosts file.
Isn't it by definition [^], the loopback?
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]
|
|
|
|
|
loopback address can exist even if /etc/hosts file dosn't have an entry indicating it. Am i missing something?
Gajendra
|
|
|
|
|
Gajendra Sharma wrote: loopback address can exist even if /etc/hosts file dosn't have an entry indicating it.
That's is true, I suppose, anyway it is not a point against my argument: since loopback is by definition the address resolved by name services, I guess that gethostbyname (or getaddrinfo [^]) will do the job.
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]
|
|
|
|
|
Thanks for your help. I could solve the problem by enumerating local interfaces using WSAIoctl and then checking loopback net with flag IFF_LOOPBACK.
Gajendra
|
|
|
|
|
|
The reason why you are not getting a response is because, the query that you have put does not have clarity. A little more explanation is expected.
|
|
|
|
|
Hi all
can you help?
part of my code i need to do this
const char * p= "ddddd";
char q[500];
I want to copy the sting in p to q[]?
|
|
|
|
|
Maybe you can try this.
#include <iostream>
int main()
{
const char * p= "ddddd";
char q[500];
strcpy_s(q, p);
std::cout << q << std::endl;
return 0;
}
|
|
|
|
|
|
const char * p= "ddddd";
char q[500];
int i;
i=0;
while (p[i] && i < sizeof(q) - 1 )
q[i++] = p[i];
q[i]='\0';
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]
|
|
|
|
|
|
Why do you complicate your life that way Are you borde today ?
|
|
|
|
|
Cedric Moonen wrote: Why do you complicate your life that way
Actually it was pathetically simple.
I'm always 'borde'!
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]
|
|
|
|
|
CPallini wrote: Actually it was pathetically simple.
Yes I know that it was simple but you are suggesting to the OP that each time he has to copy a string, he should use this code. Honnestly, I really don't think it is a good idea because it makes the code much more difficult to understand (suppose that you repeat that code in a lot of places in your code ). And apparently, that's what the OP is going to do instead of using one of the "built in" mechanism.
CPallini wrote: I'm always 'borde'
Mh, yeah, I meant bored of course
|
|
|
|
|
Cedric Moonen wrote: Yes I know that it was simple but you are suggesting to the OP that each time he has to copy a string, he should use this code.
Nope, I would suggest him to use the library functions actually. I posted the code just to show how the task could be accomplished without using such functions (as a side note to other answers).
Cedric Moonen wrote: Honnestly, I really don't think it is a good idea
I agree, because library functions are more general.
Cedric Moonen wrote: because it makes the code much more difficult to understand (suppose that you repeat that code in a lot of places in your code Dead ).
I disagree. OP should have at least a rough idea on what happens behind the curtains of the library functions. Repeating the code is a very bad practice that I would never suggest. I suppose that showing a piece of code is not a boost to 'inline' code instead of properly 'wrap the code with a function and then call it everywhere it is needed'.
Cedric Moonen wrote: And apparently, that's what the OP is going to do instead of using one of the "built in" mechanism
I'm really not so clever to guess OP intentions. Anyway I would suggest him to use library functions (that anyway are not, in my opinion, a built-in mechanism...).
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]
|
|
|
|