|
Thanks a lot your suggestion intutively promising.I will surely try, I think it should work.
|| ART OF LIVING ||
|
|
|
|
|
if there is more than one Mode in this program how to show all ( i mean if the mode like 2222 3333 44 the mode here is 3 and 2 how to make it ..
and the code below find one mode and i want the code find more than one mode
<br />
<br />
int Mode1(int a[],int mode,int freq)<br />
{<br />
int temp;<br />
<br />
mode=a[0];freq=1;temp=1;
for (int i=2;i<10;i++)<br />
{<br />
if (a[i]!=a[i-1])<br />
temp=1;<br />
else<br />
temp=temp +1;<br />
<br />
if (temp > freq)<br />
{<br />
freq=temp
mode=a[i];
}<br />
}<br />
}
<br />
THANK'S FOR ALL ...
To Be Or Not To Be
(KARFER)
|
|
|
|
|
Dear friend
It seems you need to write recursive function. I have written here small snippet
may not exactly match,but I feel it may be useful
for(int i = 2; i < 20;i++)
{
for(int k = i+1; k < 20;k++)
{
if(a[i] == a[i+1])
{
mode = a[i+1];
checkfornext(i+1);
}
}
}
checkfornext(int temp )
{
for(int l = temp+1; l < 20;l++)
{
if(a[temp+1] == a[temp+2])
{
mode = a[temp+2];
if((temp+1) < 20)
checkfornext(temp +1);
}
}
}
|| ART OF LIVING ||
|
|
|
|
|
THANL'S ALOOOT;)
To Be Or Not To Be
(KARFER)
|
|
|
|
|
Hi all:
Below is the codes I wrote:
void append(const char* inputString) {
realloc(ptr, strlen(ptr)+strlen(inputString)+1);
assert(ptr != NULL);
strncat(ptr, inputString, strlen(inputString));
ptr[strlen(ptr)] = '\0';
}
Where "ptr" is of type char*; inputString is merely a pointer pointing to a char string.
It does not seems to work properly. I am wondering why?
Thank you
|
|
|
|
|
Do you need to write it in C ? If not, try using the string class. In any case, never use realloc. Use delete and new, only, in C++. I am not sure if reallocating the memory, doesn't stomp the old values.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
i am trying to find out which column and row i hit, when i made a doubleclick on a cctrllist.
To get the row is no problem, i simply make a hit test with the coordinates of the message source.
DWORD dw = GetMessagePos();
CPoint p(GET_X_LPARAM(dw), GET_Y_LPARAM(dw));
list.ScreenToClient(&p);
int row = list.HitTest(p);
int col = ????
thanks
|
|
|
|
|
Hi,
Use CListCtrl::SubItemHitTest instead. This returns both the item and sub-item as well.
Kiran
|
|
|
|
|
How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
|
|
|
|
|
typedef is your friend when dealing with complex types:
typedef char* (*func1)();
typedef func1 (*func2)();
func2 myarray[N];
|
|
|
|
|
int test = 1 + 2 + 3;
+2 + 3 +4;
after I compile with Visual studio 6 or .net
the answer test is 6
Is there anyone know what is weird ? the compiler will not have any error message, is this kind of bug ?
Thanks for advance.
coding is just the beginning
|
|
|
|
|
Of course
int test = 1 + 2 + 3;
equals 6.
+2 + 3 +4;
is a seperate expression. Remove the first semicolon if you want to connect the two expressions.
int test = 1 + 2 + 3 +2 + 3 +4;
will result in test == 15.
|
|
|
|
|
Sofian Teja wrote: int test = 1 + 2 + 3;
Evaluates to 6 (according to Adam Riese).
Sofian Teja wrote: +2 + 3 +4;
Is an empty expression (it does nothing), always switch on your compiler warnings and you will be notified when such things happen accidentally. Related articles: Getting pragmatic with warnings, here and here.
Hope it helps.
|
|
|
|
|
Any expression can also be a statement. The statement
+2 + 3 +4;
is perfectly legal. It calculates the value and does nothing with it. (Of course, in optimized builds, the statement will be removed since it does nothing and has no side effects.)
|
|
|
|
|
hi to all!
would like to ask..
can priority be implemented using linked list?
if yes, can you please show me how?
thanks a lot!
newbie
|
|
|
|
|
Yea It can be.
The main logic change will be while "Inserting" a new item.
While Inserting a new "Item" of say "n" priority you have to check that it should be inserted at last item of the same priority but before a low priority item.
Manoj
Never Give up
|
|
|
|
|
hi manojkumarrai! thanks for the reply...
for the implementation... should i have pointer to the last item for each priority category?
thanks!
newbie
|
|
|
|
|
|
Hi all,
Can anybody plz tell me how to use GetExitCodeThread Function.
my thread object is CloseTh.I am not getting how to pass second parameter.
DWORD lpExitCode;
GetExitCodeThread(CloseTh->m_hThread,lpExitCode);
when i write this,this error is coming
cannot convert parameter 2 from 'unsigned long' to 'unsigned long *'
thanks in advance
|
|
|
|
|
DWORD lpExitCode=0;
GetExitCodeThread(CloseTh->m_hThread,&lpExitCode);
|
|
|
|
|
Whitesky was quick to answer.
neha.agarwal27 wrote: DWORD lpExitCode;
Do make a habit to initialize the variables.
Regards,
Vijay.
God may not give us what we 'want', but he surely gives us what we 'need'.
|
|
|
|
|
Read the error message. The function takes a pointer to an unsigned long but you are passing an unsigned long . (DWORD is a typedef that resolves to unsigned long .) You need to pass the address of that DWORD variable. Fixing the Hungarian prefix would be nice too.
|
|
|
|
|
how to create IPAddress control with the style IPAS_NOVALIDATE
|
|
|
|
|
|
I can't find IPAS_NOVALIDATE defined in any of my platform SDK/MSDN files.
What is it?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|