|
Even the action of getting into the telnet mode is failed.
The correct answer should be the following:
C:>telnet 127.0.0.1
Telnet>
Telnet>
But mine is:
C:>telnet 127.0.0.1
C:>
Getting nothing!The same problem with ftp.
|
|
|
|
|
It's probably because it's got no standard input connected on startup.
Also - you don't need a cmd.exe for telnet & ftp so long as you supply it with pipes for standard input and standard output. You can give it commands over standard input and gather output using standard output.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello,
I have a class TableFrame
class TableFrame : public CMDIChildWnd
{
}
I have written the following code in MainFrame where OpenNewWindow function opens a new window and WhichNewWindow function gets the active window and calls the function of TableFrame.But I am not etting the pointer of TableFrame and STATIC_DOWNCAST gives Unhandled Exception.
How do I et the active window pointer of TableFrame.
void MainFrame::OpenNewWindow()
{
CMDIChildWnd* ChildPt = CreateNewChild(RUNTIME_CLASS(TableFrame),
TITLE_MachineOpHrs, m_hMDIMenu, NULL);
TableFrame* pF = STATIC_DOWNCAST(TableFrame,ChildPt);
}
void MainFrame::WhichNewWindow()
{
CWnd* p = GetActiveWindow();
TableFrame* pT = STATIC_DOWNCAST(TableFrame,p);
pT->Insert();
}
Thanks
Pritha
|
|
|
|
|
prithaa wrote: CWnd* p = GetActiveWindow();
GetActiveWindow return the pointer the currently active toplevel window. not a child of mdi window.
You should try
TableFrame* pT = (TableFrame*)GetActiveFrame();
|
|
|
|
|
|
Hi,
i have a WCHAR variable and i need to pass it as an argument to a function which asks for CString&...
WCHAR buf[10];
void xxx::yyy(CString& rString)
i need to pass this buf in the place of rString...
can anyone help me to convert this?
Thanks,
Rakesh.
|
|
|
|
|
If the function expects a CString, you should pass in a CString.
So simply create a CString variable and pass that in.
CString str;
xxx:yyy(str);
If you want the value in buf, you can later copy it.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi Superman,
Thanks for your reply...
i actually want to read the content of a file...
If i use CString it is retrieving only the file name and not file content... rather if i use getbuffer() method, i think i can get the content..but its not accepting if i give like this xxx:yyy(str.getbuffer()) ..........it threw an error stating it cant convert wchar_t * to cstring&....
my doubt is this.. i need to copy the content of the file to that wchar variable as well as it should be passed into the function of type cstring&..
how can we do that sir?
Thanks,
Rakesh
|
|
|
|
|
Rakesh5 wrote: if i give like this xxx:yyy(str.getbuffer())
Arghh.... Never nevver use GetBuffer without having read the documentation of that function first. It doesn't make any sense to call this function here because the CString object already provides a cast operator to the same string type returned by the GetBuffer function. So, if passing the CString object directly is failing, calling the GetBuffer function will fail in the same way. Besides, doing that is really bad practice because this function is only inteded to get a way to access the internal buffer of the CString object, which is almost never needed (only in very rare conditions).
|
|
|
|
|
You *must* read the article pointed out by Cedric in his other reply to you.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Why are you using a WCHAR array instead of a TCHAR array in the first place ?
I suggest you read this article[^] first, to be able to understand the concepts. Things will probably be much clearer afterwards.
|
|
|
|
|
Thanks Moonen..
I really appreciate your timely help...
Thanks,
Rakesh
|
|
|
|
|
The function takes a reference to a CString object. You cannot, therefore, pass anything else to it. Please buy a book on C++.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
I have created a Window UI using CreateWindowEx(), than on top of that I created a Tabbed control using the same function. On each tab i have a edit control, I am not getting the messages from the edit control.
I am expecting that the mesaages should come to WM_COMMAND/WM_NOTIFIY of the parent window.
thanks in advance.
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
Code 1:
while(TRUE)
{ ..........
}
if(1) { ......... }
Compiler warning:- Constant data in conditional statement.
How to get rid of this?
Can i do like.....
bool flag = TRUE;
while(flag) {.......}
Code 2:
unsigned short a = -1;
Compiler warning:- Possible loss of data...
How to get rid of this warning?
Can i do.....
unsigned short a = (ushort)-1;
Code 3:
char a[10];
char b[20] = "H";
strcpy(&a[2], b);
Now i want to convert this function to strcpy_s, where in i have to pass the buffer size..
so can i do like...... strcpy_s(&a[2], sizeof(a), b);
Can i do like that? Or is that i just need to pass the sizeof that particular array index, like sizeof(a[2])
Any help is welcome....
Thanks in advance.
|
|
|
|
|
Hi,
AFAIK there is only one way to create an "eternal loop" that should never generate a warning, whatever smart the compiler is:
for( ; ; ) {
...
}
since this is legal C/C++ code that clearly shows no exit condition. Everything else, checking on 1 or TRUE or a variable with a constant value, is bound to be flagged when compilers are smart enough, their intent is to WARN you that maybe you made a mistake.
The same holds true for empty loops:
while (someCondition); may generate a warning (unintentional empty loop, maybe due to an extraneous semi-colon), whereas
while (someCondition) {}
is fine since now the compiler must realize you typed two characters to create an empty code block.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
dipuks wrote: unsigned short a = -1;
Compiler warning:- Possible loss of data...
How to get rid of this warning?
This is absurd. Why do you want to assign a signed value to unsigned type? What's wrong in using just short ?
|
|
|
|
|
N a v a n e e t h wrote: This is absurd. Why do you want to assign a signed value to unsigned type?
This is not as uncommon as you might think.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
dipuks wrote: while(TRUE)
{ ..........
}
As suggested by Luc, use for ( ; ; )
dipuks wrote: if(1) { ......... }
Why would you ever want to do this?
You really do not need the condition check here.
dipuks wrote: unsigned short a = -1;
Assigning a signed number to an unsigned variable does not make sense.
You should either change the unsigned variable to a signed variable.
Or assign the value 0xFFFFFFFF to the unsigned variable.
A lot of work has been done in this field. Look at Inside SafeInt[^]
dipuks wrote: strcpy_s(&a[2], sizeof(a), b);
You may have to do strcpy_s(&a[2], sizeof(a) - 2, b);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
these are discussable item, and to tell a long story short, there are different ways possible.
Code 1: writing loops with no "exit strategy" isnt fine
Code 2: common way to initialize with invalid data
Code 3: a[2] = 'H';
+ bug, buffer is false computed !!! strcpy_s(&a[2], sizeof(a) - 2, b);
+ i would use sprintf-style funktion "H%s" for extensionable coding
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
My title is probably not very well phrased, but here is the problem. Let's say I've got functions a() , b() , where a() calls b() , and b() calls vector<T>::iterator iter = someVector.begin() .
b() needs to pass this iterator down to a() via a void* mechanism, without returning it (essentially using reference passing), so more explicitly, the two functions are:
void a(void*& param);
void b(void*& param);
The problem is, we can't simply do something like this:
vector<T>::iterator iter = someVector.begin();
param = reinterpret_cast<void*>(iter)
This is because the compiler (MSVC9) will complain about trying to cast an iterator to a void*:
error C2440: 'reinterpret_cast' : cannot convert from 'std::_Vector_iterator<_Ty,_Alloc>' to 'void *'
Likewise, I can't do something like...
vector<T>::iterator iter = someVector.begin();
param = reinterpret_cast<void*>(&iter)
...because even though this will compile, it will not work because begin() actually returns an iterator object and not a pointer to some memory location, so the memory address of that object will go out of scope (not sure when, but I'm guessing when you leave b() ). So, because I can't do any of this, I thought that maybe I could do a memory copy of the iterator, pass it up as a void*, and then cast it back to an iterator, so something along these lines:
vector<T>::iterator iter = someVector.begin();
void* mem = malloc(sizeof(vector<T>::iterator));
param = mem;
And on the flip side, in order to decode my data, I'd do something like this:
vector<T>::iterator = reinterpret_cast<vector<T>::iterator>(param);
I'm wondering whether or not this idea of mine is feasible or will cause me many problems, or if there is a better way of doing what I'd like to do, given the limitations (can only pass by void* reference).
Thanks.
|
|
|
|
|
Apart from the fact you're using malloc, the last idea's OK.
Use new instead - it's C++, man!
param = reinterpret_cast<void*>(new vector<T>::iterator(someVector.begin()));
Remember to delete it afterwards as well....
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Yeah, well, the way I see it, malloc just does a simple memory allocation, whereas new also calls the parameterless constructor. In this case, since I'm overwriting everything, I figured malloc was the better way, but from my testing, it seems that new works as well. I've managed to get some sample code working, and it seems to be fine when T = int, but I've been told that it may not work where T is a more complicated class.
|
|
|
|
|
Should be fine, no matter what T is - an iterator generally only holds a reference to an item in a container (for simple, container iterators).
Cyrilix wrote: new also calls the parameterless constructor
new will call whichever constructor you specify. In my example, I use teh copy constructor.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
In any recent version of VC, iterators are not simple pointers. There is some debug info kept around to detect dangling iterators and iterators that point outside of their containers. So doing a straight memcpy will work only as long as the original iterator exists.
What about this:
vector<T>::iterator* piter = new vector<T>::iterator ( someVector.begin() );
void* pv = (void*) piter;</T></T> ? Last modified: 5hrs 10mins after originally posted -- fixde tpyo
--Mike--
|
|
|
|