|
Because we couldn't use string functions. And I don't see how u explain what happens here..
Kuniva
--------------------------------------------
|
|
|
|
|
Kuniva wrote:
Because we couldn't use string functions.
Fair enough.
Kuniva wrote:
And I don't see how u explain what happens here..
What's to explain? I trust you know that getchar() buffers input while getche() does not. That's why I suggested using it.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yea.. my bad, sorry.
Kuniva
--------------------------------------------
|
|
|
|
|
The problem here is that you've allocated a char array of size 21, i.e. with subscripts 0 to 20. Then, you're accepting input of length up to 20 characters, to fill the array you created. This is where the problem occurs, because in actual fact you should only be accepting 19 characters of input, since the twentieth needs to be the NULL string terminator. To clarify, note that str[21] is NOT inside the bounds of the array.
Hope this helps,
--
Andrew.
|
|
|
|
|
Thats not what I was asking, it doesn't have anything to do with my question. What does the size of the array have to do with the while loop not really running? If u don't believe me change it and see for urself.
What I was asking is why when u enter like 45 characters on the command line and press enter, it'll print three lines of output. It's supposed to simply stop at 20 chars (or 19 if u fix it whatever) and show the output, but it doesnt, it just keeps on accepting input even though i should become larger than 20, its like it doesnt execute the body of the loop at all..
Kuniva
--------------------------------------------
|
|
|
|
|
NVM, got it, the getchar() function just behaves differently from what I anticipated. It doesn't just wait for one key to be pressed and then return the result like i thought, instead u can enter as many chars as u want untill u hit return and they all end up in the input buffer, and it returns only the first char u enterred.. kinda weird but whatever.
Kuniva
--------------------------------------------
|
|
|
|
|
Does Any one has any idea how to create a font; that is create a font that support new characters symbols. think of it as creating a new font for a new language with unique characters and symbols.
|
|
|
|
|
How to get untransparent area (RECT) of icon?
|
|
|
|
|
BITMAPINFO &bmInfo = *(LPBITMAPINFO)hDIB Variable Declarations for bmInfo!!!
Hi, what does means the & ? what kind of datatype about bmInfo?? pointer???
Thanks
|
|
|
|
|
This is reference to an object. However defining reference not as parameter of function is bad programing style! Remember this.
|
|
|
|
|
Hi,
I want to get files list created,modified and last accessed on the basis of dates(i.e between 2 dates).How Can I do that.
Drushti
|
|
|
|
|
Use the CFileFind class to iterate through all the files in a specified folder (or subfolders, if you use recursion). From there you can get all the necessary file info for each file it iterates through.
while(true)
{
TryToLearn("C++,MFC");
}
My articles[^]
bdiamond
|
|
|
|
|
Hi ,
I want to get the different File types with there Icons in the Combo box . How can I get it?
Drushti
|
|
|
|
|
Please explain furthur. I do not understand what you are asking.
John
|
|
|
|
|
Ok John,
Here are more details...
What I want is when I click the combo box down arrow,different types of file format ,for example:- Header file, source file,mp3 file, adobe acrobat file,Microsoft word file and so on (i.e all supported and recognized file format by OS), should be displayed.
To have a clear idea ...if u r using Windows 2000 professional , then click Search -> for Files or Folders ->Search Options (hyperlink)->Type->Combobox.
Hope Now I nust have cleared my point.
Drushti
|
|
|
|
|
me think you need to check the registry ( under HREF_CLASSES_ROOT ).
check the "OpenWithList" entries.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
MSDN indicates that windows creates a message queue along with each thread that is created. If I create a thread with CreateThread(), how do I gain access to the message queue?
The reason I ask, is that I would like a worker thread to use Winsock2 Async functions. Therefore can I use the thread's message queue to receive message based socket notifications.
Can anyone point me in the right direction?
Many thanks.
|
|
|
|
|
When you make a worker thread, it does not initially have a message queue. The first time you call a message queue-related API, a queue is created. To create a queue, use this:
MSG msg;
PeekMessage( &msg, (HWND) INVALID_HANDLE_VALUE, WM_NULL, WM_NULL, PM_NOREMOVE );
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
Michael,
Many thanks. It all helps!
Spencer
|
|
|
|
|
MSDN indicates that windows creates a message queue along with each thread that is created
That's not exactly true. Threads only have a message queue if they call one of the thread processing functions, such as GetMessage, PeekMessage, or create a window.
Therefore can I use the thread's message queue to receive message based socket notifications
Yes, absolutely. It is easy to use a background thread to handle socket communication. But, before I give a brief description of how to handle Async sockets, I should mention there is a better method. Use event based sockets (WSAEventSelect instead of WSAAsyncSelect). The performance for event based is tremendously better than for async sockets. Message processing uses a lot of overhead. If your data load is small, then it won't matter too much which way you go, but if you expect high data streams, async sockets simply won't keep up.
Note: MFC's CAsyncSocket does not support event based, but it is not as hard to do it by hand as it may seem).
Now for async sockets:
Create your background thread. Inside your thread, create a non-visible window as a child of your main window. Use this background window to receive all socket notifications. In other words, pass this window handle to the AsyncSelect function.
If you're using MFC, create a CWinThread derived class. Use this class for the AfxCreateThread function. Inside the InitInstance function for this thread class, create your window and set it as the m_pMainWnd for the thread (just like what happens with CWinApp and CMainFrame). The built-in "Run" function will properly handle the message processing. Now just add an appropriate ON_MESSAGE handler to your background window class (just derive from CWnd).
|
|
|
|
|
Bill,
Many thanks for your helpfull reply. On examination of the WSAEventSelect, it looks like the better way to go.
However, I have some questions around the Thread and Window issue. Currently I'm not using CWinThread, I'm using the basic CreateThread windows function. If I was to create a new window, should I create it using the MFC CDialog::Create method or another way. Given the approach I'm currently using, I'm at a loss on how to add a message handler for the thread/ window.
Reading your text:
Bill Buklis wrote:
create your window and set it as the m_pMainWnd for the thread
Can I achieve this using my approach for creating the thread?
Any help would be much appreciated.
Spencer
|
|
|
|
|
If you go with WSAEventSelect, then no window or message queue is necessary and in fact is undesired. Also, if you're using MFC (sounds like you are), then you should not use the CreateThread function directly. It can confuse the runtime library and some thread specific states for MFC. Even without MFC there is a beginthread function for the runtime library.
Use AfxBeginThread (it will call the RTL's beginthread function for you). There are two versions of this function - one which uses CWinThread and one which simply calls a function like CreateThread.
|
|
|
|
|
I'm a bit of a newbie to the winsock stuff and mfc. When I compile the code with WSAEventSelect I get error C2065: 'WSAEventSelect' : undeclared identifier. I've tried including winsock2.h.
Any ideas?
Thanks in advance.
Spencer
|
|
|
|
|
Hi! I've encountered a new problem. Normally one declares an object of the form <class-name> <object> . But I had errors when i declared the object using the above format like syntax error , missing type specifiers or storage specifiers. When I declared using class <class-name> <object> the error simply vanished. What could be the reason??
Thanks in advance!!
Suman
|
|
|
|