|
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]
|
|
|
|
|
Some would reach for the off the self "pirelli" wheel, others fashoin themselves the "pallini" wheel... both are high quality
|
|
|
|
|
killabyte wrote: Some would reach for the off the self "pirelli" wheel, others fashoin themselves the "pallini" wheel... both are high quality
Well, personally, I would never use hand-crafted tyres on my GSR.
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]
|
|
|
|
|
Well, you've not had a C++ answer using STL yet...so, just because:
const char * p= "ddddd";
char q[500];
std::copy(p, p+strlen(p), q);
Of course, it is less efficient than the pure C answers, as it iterates through p twice.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: // needs #include
const char * p= "ddddd";
char q[500];
std::copy(p, p+strlen(p), q);
That's hybrid!
const char * p= "ddddd";
char q[500];
std::string s(p);
s += '\0';
s.copy(q, s.length());
(I know, that's, well..., ugly! )
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: That's hybrid
Hybrid's[^] good these days, maaaaan (allegedly).
CPallini wrote: // needs a different #include!
const char * p= "ddddd";
char q[500];
std::string s(p);
s += '\0';
s.copy(q, s.length());
(I know, that's, well..., ugly! )
Well, if I'd known you were bringing strings, I'd've used this:
const std::string p = "ddddd";
std::string q;
q=p;
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: const std::string p = "ddddd";
std::string q;
q=p;
std::string q = "ddddd";
FFY
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]
|
|
|
|
|
Hello,
I have a 2D waveform data (Sine/Square/Triangle). Could some one tell me how to calculate period and duty cycle from it.
Note:
I am new to this forum, if this is a wrong place to post this topic, some one re-direct me to correct place.
Thanks.
modified on Tuesday, July 14, 2009 2:47 AM
|
|
|
|
|
Hi,
I'm not ure what you asking, a quick Google should tell you how to calculate period & duty cycle. Try to think of a more specific programming question and perhaps someone here can help you.
Ali
|
|
|
|
|
I am just trying to implement the period and duty cycle calculation in a C++ class based on the waveform array data. Trying to figure out some formula to find those values.
|
|
|
|
|
Period - find the max/min values of your waveform. Now look for the times when the waveform crosses (min+max)/2. The period should be double the time between adjacent crossings of that value.
Alternatively, calculate the FFT of the waveform and look for the big peak - that'll show dominant frequency in your signal.
Duty cycle[^] - Wikipedia defines as Duty cycle is the proportion of time during which a component, device, or system is operated. First you need to decide what the 'active' state of your waveform is and work out what fraction of time it's active.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|