|
I've reinstalled Windows on my computer and then installed VS.NET 7.0 and the program isn't working on my computer either. I have the .NET framework installed. Somebody help. This is strange.
|
|
|
|
|
umm. I am trying to convert some existing code I found that performed a quicksort on an array using leftmost element as pivot. I want to make the pivot selection random but I have run into logic errors for a long time. It seems to work sometimes now but not all the time so there is still something wrong and I don't know what. If someone could take a look and tell me where i went wrong I would appreaciate it.
#include <stdlib.h>
#include <stdio.h>
#include <process.h>
#include <time.h>
#define NUM_ITEMS 100
int numbers[NUM_ITEMS];// = {6,24,80,4,19,84,1,10,13,7};
void print(void);
void quicksort(int beg, int end);
void sort(int beg, int end);
void swap(int left, int right);
int pivot(int beg, int end);
void selectsort(int left, int right);
void main(void)
{
int i;
//seed random number generator
srand((unsigned)time( NULL ));
//fill array with random integers
for (i = 0; i < NUM_ITEMS; i++)
numbers[i] = rand();
//perform quick sort on array
quicksort(0, NUM_ITEMS);
print();
exit(1);
}
void quicksort(int beg, int end)
{
sort(beg, end - 1);
}
void sort(int beg, int end)
{
int position;
if (beg > end)
return;
if (beg == end)
return;
position = pivot(beg, end);
sort(beg, position - 1);
sort(position + 1, end);
}
int pivot(int beg, int end)
{
int left = beg, right = end, pivot;
int rand_subscript;
rand_subscript = (int) ((right-left) * rand() / (RAND_MAX + 1)) + left;
pivot = numbers[rand_subscript];
while ((numbers[left] <= pivot) && (left < end))
{
left++;
}
while (numbers[right] > pivot)
{
right--;
}
while (left < right)
{
swap(left, right);
do
{
left++;
}while ((numbers[left] <= pivot) && (left < end));
do
{
right--;
}while (numbers[right] > pivot);
if (right == rand_subscript)
{
rand_subscript = left;
}
}
if ((numbers[right] != pivot) && (numbers[rand_subscript] == pivot))
swap(right, rand_subscript);
print();
return right;
}
void swap(int left, int right)
{
int hold;
hold = numbers[left];
numbers[left] = numbers[right];
numbers[right] = hold;
}
void selectsort(int left, int right)
{
int l = left, r = right;
int ltemp, value, l_inc;
for (l;l<right;l++)
{
l_inc = l + 1;
ltemp = l;
value = numbers[l];
for(l_inc;l_inc<=right;l_inc++)
{
if (numbers[l_inc]<value)
{
ltemp = l_inc;
value = numbers[l_inc];
}
}
numbers[ltemp] = numbers[l];
numbers[l] = value;
}
}
void print(void)
{
int i;
for (i = 0; i < NUM_ITEMS; i++)
{
printf("%i, ", numbers[i]);
}
printf("\n\n");
}
|
|
|
|
|
FreeLemons wrote:
rand_subscript = (int) ((right-left) * rand() / (RAND_MAX + 1)) + left;
I think this should be:
rand_subscript = (rand() % (right - left + 1)) + left;
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I am using Visual C++ 6.0 and am having problems with the threads dialog box. I find that after suspending execution and opening the threads box, sometimes not all the threads in the process are displayed. I can see the threads in a suspended state in Spy++ though.
Has anyone encountered this problem? Any help would be appreciated.
thanks
Man Learns from History that he never learns from History
|
|
|
|
|
I'm sure there's a C++ expert who can explain who to overload the indirection to a member and deferencing a pointer.
<br />
class A{<br />
int m_i;<br />
float *m_pf<br />
};
My questions are how to use operator -> to return m_i, ->* to return m_pf.
What parameters to I use when create the method.
Does it work when you create a pointer to an object of type classA?
|
|
|
|
|
Well techincally it would be like this:
class A
{
public:
int m_i;
float *m_pf;
int operator->() const
{
return m_i;
}
float& operator*() const
{
return *m_pf;
}
};
But - while the * operator makes sense, the -> makes none at all. Why would you want a -> operator to return a basic type? (ie not a pointer to a class)
In fact, I belive if you compile the above you will get:
warning C4284: return type for 'A::operator ->' is 'int' (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation)
return type for 'identifier::operator –>' is not a UDT or reference to a UDT. Will produce errors if applied using infix notation
The operator–>( ) function must return either a pointer to a class or an object of or a reference to a class for which operator–>( ) is defined.
The following example causes this warning:
class C
{
public:
int operator->(); // warning
};
It is meaningless to apply the member access operator to fundamental data types that have no member access. This warning message will appear when this happens.
|
|
|
|
|
It seems if I try to delete a record programmically using ADO with special characters (i.e Â) I will always get an unhandled exception error. But if I delete all records with special characters in them then run the delete program again, it works fine. Does this sound like a bug in ADO or did I forget something extra for special characters?
thanks!
|
|
|
|
|
How did you access your DBMS? Through ODBC using ADO?
Is the working program using the same database access engine? (like ODBC driver or BDE or others)
Sometimes some drivers do not support certain SQL syntaxes or characters. (mostly to maintain compatibility across platforms like ODBC)
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Thanks! However I noticed something strange in the DB and believe the problem occurred because for some reason unknown, duplicate records were inserted especially where a primary key has been defined and I think it bombed on not knowing what to delete or just that the rules of a primary key field were broken with the duplicate records. [ ]
oh well...
|
|
|
|
|
Hi...
PLZ.. let me know any hint to manage size of CFormView dynamically...
Thanks...Have a Nice Life
---Sumit Kapoor---
|
|
|
|
|
Describe what the main windows.
Kuphryn
|
|
|
|
|
Hi all,
I created a template to convert any type, with defined "<<" to string.
But it hanges under .NET after some hunderd executions.
Can anybody see a problem in it?
Thanks in advance,
Boni
#include <sstream>
template<class T> string tostring(T i)
{
stringstream _tmp;
_tmp<<dec<<i;
return _tmp.str();
}
|
|
|
|
|
|
dec means decimal, see stl ref
|
|
|
|
|
I posted this yesterday but it sank under the various other requests ...so reposted this again :
hi !
I was testing out skinmagic demo for one of my apps,and came accross a few problems ..maybe experienced users can help me out on this.
problem 1 :
when i used irregular shaped dialog windows, the edges showed up as having a faint magenta lines ( i used magenta as my transparent color ).I made the image using photoshop 24 bit bmp,without any drop shadow.Can anyone tell me how to get rid of these edges?in the examples i saw dialog boxes with more complicated edges than mine but those didn't have a problem, and i am unable to find out the reason for this.Can anyone exolain why this happens ?
problem 2: i had a pulldown menu in my app, and when i skin it , the pulldown menu dissapears ! the popup menu (right click ) stays though...i mean it;s properly invoked on right click, but not the pulldown menu.
problem 3: As i said before i am using an irregular shaped dialog box in my main window.after skinning , the messageboxes are also assuming the same shape, which i do not one.i want my mnessageboxes to be plainer.Would specifying a control ID for the framedialog or the shapedialog help ?How can use a diff shape for my messagebox than my other dialog boxes?
I would be glad if anyone can solve my doubts.Thanks to all the contributirs in advance
Regards
Kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason, huh ?"
|
|
|
|
|
I'm afraid I've never heard of Skinmagic but why don't you contact its developers and surely they can help with these basic issues.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hi..Checkout this...
Problem 1:-----------------------
Solution 1: Please position mask at right positon. your image & mask are not overlap exactly.that's not matter which tool you used to create background..as I always use painbrush.
Problem2:--------
Solution 2: this is your coding problem..please check again.
Problem 3:-----------
Solution 3: You sud use your own bug tracking system.. How? Make a Dialog and place static text on that. check error & show & use that dialog. One other way you can customize this by storing bitmap(and mask) setting in file or database. & while starting application check that file or database & use bitmap and mask according to that..
OK! Bye...
Sumit Kapoor
---Sumit Kapoor---
|
|
|
|
|
Hi all,
I would like to write a program that allows me to password protect applications such as Word and I.E. My, vision is that when one of these apps is launched my app would open first and ask for the password and then either continue or kill the app. Would you have any ideas to point me in the right direction?
Thanks in advance for your help,
bacon
|
|
|
|
|
i did soemthing like this using API hooks.study Ivo Ivanov's API hooking revealed for more info.
Hope it helps
Regards
Kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason, huh ?"
|
|
|
|
|
what i would do, is look for windows with those classname and titles of the windows you wish to protect, (you can use Spy++ to get them)
then hide them using the Showwindow() function
and bring up your password dialog
if they enter the right password show the window/s again using ShowWindow()
|
|
|
|
|
Anonymous wrote:
...when one of these apps is launched my app would open first...
You might see about modifying the HKEY_CLASSES_ROOT\exefile\shell\open\command registry key. Change the (Default) value to myprog.exe "%1" %* and see if that works.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
A big thank you to everyone!
--bacon
|
|
|
|
|
Dear Friend,
My application works fine in Release mode but it gives an error or displays an abort dialog when I close window in Debug mode.
Please write to me the reason behind this.
Thanking you in advance....
Billar
|
|
|
|
|
maybe it;s giving an assertion error.then is shud give a message like "assertion failed in file so and so in line so and so " .Open up the file and read up that line.Maybe you have done something illegal....
Regards
kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason, huh? "
|
|
|
|
|
Billar wrote:
Please write to me the reason behind this.
*laughter*
Probably because you have a bug. Without a description of any kind, however, it's quite difficult to know what the problem might be...
|
|
|
|