|
// Next time just use msdn.
Example
/* QSORT.C: This program reads the command-line
* parameters and uses qsort to sort them. It
* then displays the sorted arguments.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int compare( const void *arg1, const void *arg2 );
void main( int argc, char **argv )
{
int i;
/* Eliminate argv[0] from sort: */
argv++;
argc--;
/* Sort remaining args using Quicksort algorithm: */
qsort( (void *)argv, (size_t)argc, sizeof( char * ), compare );
/* Output sorted list: */
for( i = 0; i < argc; ++i )
printf( "%s ", argv[i] );
printf( "\n" );
}
int compare( const void *arg1, const void *arg2 )
{
/* Compare all of both strings: */
return _stricmp( * ( char** ) arg1, * ( char** ) arg2 );
}
Output
[C:\code]qsort every good boy deserves favor
boy deserves every favor good
Aizik Yair
Software Engineer
|
|
|
|
|
thank you very much for you guys help. i really appreciate it. i dont have a MSDN library so i couldnt do this problem. thank you very much again.
Thank you very much,
John
Aloha from Hawaii
|
|
|
|
|
John Cruz wrote:
i dont have a MSDN library
Have you seen http://msdn.microsoft.com/library ?
Kind regards to Hawaii.
|
|
|
|
|
I have created an Edit control dynamically with the help of CEdit class using the CreateEx member funtion...How to add a message handler funtion for that control. For example KeyPress event i want to handle. I would be greatfull if anybody let me know the answer for this question.
Reg
Guru
|
|
|
|
|
try using class wizard
Aizik Yair
Software Engineer
|
|
|
|
|
Copy the code, generated for edit events in a dialog by classWizard, to your project. Note, that you must specify unique ID for the edit for correct message handling.
|
|
|
|
|
Hi,
In my application, I have a given process (I get its identifier as a DWORD, a pseudo HANDLE and its name) and a given mutex name and I have to know if this given mutex belongs to the given process.
Does anybody know how to proceed ?
Thanks,
Robin.
|
|
|
|
|
Can you describe situation with more details?
For what purpose you want to check is mutex belong to given process?
Maybe you can create a table of pair mutex-PID in shared memory and when needed check is mutex belong to Process. (??? MapViewOfFile function can help with memory sharing ???)
|
|
|
|
|
Please, if somebody has ready solution (function for counting of words in a string), write it here. I just want to obtain number of words in LPSTR string.
Thanks!
|
|
|
|
|
You can use strtok. First define a string of separators and then use strtok to find all matching tokens and count them.
Best regards,
Alexandru Savescu
|
|
|
|
|
Thanks! Here was example:
* STRTOK.C: In this program, a loop uses strtok
* to print all the tokens (separated by commas
* or blanks) in the string named "string".
*/
#include <string.h>
#include <stdio.h>
char string[] = "A string\tof ,,tokens\nand some more tokens";
char seps[] = " ,\t\n";
char *token;
void main( void )
{
printf( "%s\n\nTokens:\n", string );
/* Establish string and get the first token: */
token = strtok( string, seps );
while( token != NULL )
{
/* While there are tokens in "string" */
printf( " %s\n", token );
/* Get next token: */
token = strtok( NULL, seps );
}
}
Output
A string of ,,tokens
and some more tokens
Tokens:
A
string
of
tokens
and
some
more
tokens
|
|
|
|
|
Who can point me to sample or article about using LPSECURITY_ATTRIBUTES in AfxBeginThread function?
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
What's the difference between COM and COM+?
If I create a COM DLL using VS.NET on XP, does this automatically mean it's a COM+ component?
Regards
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
|
Thanks Michael
So basically COM+ is COM plus some extra stuff
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Some problems on VC++ activex:
i try to add-in a telephony class from the below directory
Components and controls gallery->Registered Active X
control->Telephony class
Xtel.dll
but when i try to execute the application,it show application error:
[The instruction at "0x676c49ee" referenced memory at "0x00000008".The
memory could not be "read".]
and when i try to debug it,it show
676C49EE call dword ptr [ecx+8]
Do anyone have any idea what happen on it?
thanks...
|
|
|
|
|
Dear all,
In a dialog-based application, I have a main window. I want set it
with a changable size of the window as usually used window's application.
How to maximize, minimize or freely change the size of the window in
a dialog based application?
Thanks in advance!
xyz
|
|
|
|
|
Change the window styles.
First, in order to be able to resize the dialog you will want to remove the WS_DLGFRAME style from the dialog and replace it with a WS_THICKFRAME style.
In order to be able to maximize the dialog you will want to add the WS_MAXIMIZEBOX style to the dialog.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
And you can do all that in the Dialog editor.
Best regards,
Alexandru Savescu
|
|
|
|
|
Hi!
I have a preview control which draws metafiles. How can I draw metafile, but with colors which have been defined in my application?
Thanks for help!
|
|
|
|
|
I have got an anwser...
Enumerate metafile, and just before PlayMetaFileRecord() select desired pen.
|
|
|
|
|
Hi,
I have created a win32 Dll in Visual C++ .Net. I tried to call the functions from the dll from another VC++ .Net Win32 Application project. I have used the Load library method to load the dll and its functions. In the first function call from the dll it gives the following error
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
I tried with differenct calling conventions __stdcall and __cdecl. I have tried the same project with the static library. It's working fine.
What i have to do to avoid this error?.
Thanks in advance.
Regards,
RajaSingh R.
|
|
|
|
|
After your call to LoadLibarary are you calling GetProcAddress to get the pointer to the function in the DLL?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Yes I have used the GetProcAddress and get the pointers for the functions and used these pointers for calling the functions. I followed this procedure correctly.
|
|
|
|
|
This may sound like a stupid question, but are you trying to call a non-static member function directly (read: without using an instance of the containing class)? I only ask because I have seen someone try somethig like that before, and of course, it does not work correctly.
The error you are seeing I have encountered only when there was a calling convention mixup, or the function pointer was typedef ed incorrectly. For example, if the function in the DLL expects 4 parameters, but my function pointer is typedef ed to take only 3.
Peace!
-=- James.
"Fat people are hard to kidnap."
(Try Check Favorites Sometime!)
|
|
|
|