|
I didn't even look through the code, but that is truly awesome.
SilverShakin - step into the debugger sometime to see what amazingly huge negative numbers an unassigned int gets as a default value. One thing I like about C# - it sets sensible default values for variables.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
M_Name is probably NULL and you're trying to deference it.
You can make your code look different by wrapping it in a <pre> tag, but of course then you need to type & lt and & gt ( without the space ) to get your < > characters.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
int the for loop
the
for(int inc;
the int initializes, or defines inc as an intiger... therefore i do not need to define it anywhere else... but ill look over it and see if i made a mistake...
Thanks all!
M_Name is = NULL,.... hmm im thinking... ill go and change some things... if i cant figuere it out, ill jump back on
Thanks again!
~SilverShalkin
|
|
|
|
|
The problem is exactly as has been stated - you define an integer, but do not give it a value. It's value will be in the order of -80,0000. You need to put int inc = 0, not just int inc.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
ok, ok... i thought you ment that i had to int inc... and i responded by that i have already... but i got the main point... i changed the for n loop to:
for(int inc = 0;inc < NN;inc++)
and it worked.. thanks! But i still have the problem with the unhandled... i didnt have time to change some things but, ill keep your responses in mind
thanks for the help all!
~SilverShalkin
|
|
|
|
|
Have you traced to see if your variable being referenced is NULL, or added a check to alert you to this case ? Checking if a variable is valid is always good - initialise all pointers to NULL, check if they are NULL before dereferencing or calling methods on them.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
please initialise the Loop Running variable mnc in to zero..
ie you must for(int mnc=0;mnc
|
|
|
|
|
i did set it = to zero,... for the most part, that fixed it
Thanks!
~SilverShalkin
ps... I'll work the debugger on the NULL pointers
Thanks!
|
|
|
|
|
I need to be able to create an image where I can specify a point (this one being the center) and a second point that is X° from the first point. I then need to be able to draw a straight line from point 1 to point 2. It would also be nice if I am able to label both points. The two points represent the direction or bearing from the first point (From) to the second point (To). This is for the web, so I thought that Office Web Components would be best. If it would be simpler to create something in C++ and then to just call a function to produce this image, I would be very appreciative if someone could point me in the right direction. I don't regularly do C++ development, but have played with it in the past.I will know the X° that the 2nd point is from the first. Does anyone have any ideas for this? Thanks in advance.
Nick Parker
|
|
|
|
|
Can anyone help me fix this. i am trying to sort the y's of my sprite from highest to lowest values and then print it out. this is what i have but my compiler wont compile it. can anyone kind enough to help me fix this to allow it work. anyways, thank you very very much. i really appreciate it.
#include <iostream>
using namespace std;
struct SPRITE
{
int x;
int y;
};
// Maximum number of sprites
const int N_SPRITES = 10;
// Array of sprites
SPRITE sprites[N_SPRITES];
bool Compare (const SPRITE &one, const SPRITE &two);
/* Pre: Enter a Sprite value for one and two
* Post: Compares all of both strings
*/
int main()
{
int value;
for (int i=0; i<n_sprites; i++)
="" {
="" cout="" <<="" "enter="" a="" value:="" ";
="" cin="">> value;
sprites[i].y = value;
}
int* begin = &sprites[0];
int* end = &sprites[9];
sort(begin, end, Compare);
for (i=0; i
|
|
|
|
|
Knowing the error would help us, but I suspect it's that you use Compare before you define it. Move Compare to the top of the file, and if that doesn't work, tell us what the error is.
It's also better form not to use all of namespace std, try using std::sort; and using std::cout; instead.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
What header is sort under? thank you very much Christian
Thank you very much,
John
Aloha from Hawaii
|
|
|
|
|
Oh - your one include was iostream and your error was unable to find sort ? It's in algorithm.
You'll still need to move Compare so it's defined before you call it, or forward declare it.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian Graus wrote:
Oh - your one include was iostream and your error was unable to find sort ? It's in algorithm.
You'll still need to move Compare so it's defined before you call it, or forward declare it.
i got both of that and i have included it like this:
#include <iostream>
#include <algorithm>
using std::sort;
using std::cout;
using std::cin;
struct SPRITE
{
int x;
int y;
};
// Maximum number of sprites
const int N_SPRITES = 10;
// Array of sprites
SPRITE sprites[N_SPRITES];
bool Compare (const SPRITE &one, const SPRITE &two)
/* Pre: Enter value for one and two
* Post: Compares all of both strings
*/
{
return (one.y < two.y);
}
int main()
{
int value;
for (int i=0; i<n_sprites; i++)
="" {
="" cout="" <<="" "enter="" a="" value:="" ";
="" cin="">> value;
sprites[i].y = value;
}
sort(sprites[0], sprites[9], Compare);
for (i=0; i
|
|
|
|
|
Error number one is because you don't check the 'show message as is ( no HTML )' box below your post.
Error number two is because you're not facing east when you program
Error number three is because you're using an array instead of std::vector.
Seriously, check the box so I can see all your code, tell me what the errors are, and then I might be able to help more.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
sorry about that Christian. here is my code now:
#include <iostream>
#include <algorithm>
using std::sort;
using std::cout;
using std::cin;
struct SPRITE
{
int x;
int y;
};
// Maximum number of sprites
const int N_SPRITES = 10;
bool Compare (const SPRITE &one, const SPRITE &two)
/* Pre: Enter value for one and two
* Post: Compares all of both strings
*/
{
return (one.y < two.y);
}
int main()
{
// Array of sprites
SPRITE sprites[N_SPRITES];
// Number value
int value;
for (int i=0; i<N_SPRITES; i++)
{
cout << "Enter a value: ";
cin >> value;
sprites[i].y = value;
}
sort(sprites[0], sprites[9], Compare);
for (i=0; i<N_SPRITES; i++)
{
cout << sprites[i].y;
}
return 0;
}
1st error: error C2784: '_Ty *__cdecl std::_Val_type(const _Ty *)' : could not deduce template argument for 'const *' from 'struct SPRITE'
2nd error: error C2784: '_Ty *__cdecl std::_Val_type(const struct std::iterator<_C,_Ty,_D> &)' : could not deduce template argument for 'const struct std::iterator<_C,_Ty,_D> &' from 'struc
t SPRITE'
3rd error: error C2780: 'void __cdecl std::_Sort_0(_RI,_RI,_Ty *)' : expects 3 arguments - 4 provided
c:\program files\microsoft visual studio\vc98\include\algorithm(541) : see declaration of '_Sort_0'
C:\DOCUMENTS AND SETTINGS\JOHN CRUZ.JCRUZ495\MY DOCUMENTS\MY PROJECTS\C++\Sort\main.cpp(46) : see reference to function template instantiation 'void __cdecl std::sort(struct SPRITE,struct SPRITE,bool (__cdecl *)(const struct SPRITE &,const s
truct SPRITE &))' being compiled
hey am really sorry for not providing what the errors were earlier. well anyways. I REALLY APPRECIATE ALL YOU GUYS HELP
Thank you very much,
John
Aloha from Hawaii
|
|
|
|
|
Sorry - it was obvious all along. You need to pass in &sprites[0] and &sprites[9]. I'm not sure this will work - it expects begin and end, and end is one PAST the last item in the array, so sprites[9] may not be sorted - therefore I would pass in &sprites[0] + 10 as the second argument.
It could also be cleaned up in other ways - you could use mem_fun_ref and have the sorting function be a member of your struct. Check out my article on functors for more info.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Thanks for the help Christian
Thank you very much,
John
Aloha from Hawaii
|
|
|
|
|
Glad to help )
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian Graus wrote:
Error number three is because you're using an array instead of std::vector
lol!
Signature space for rent. Apply Within.
|
|
|
|
|
I'm writing an application to utilize 30 external processors, and I would like to have 2 threads open for each chip (monitoring and control).
The program is an MFC app, and I'm using AfxBeginThread to launch each thread. This works great up to 56 threads, but after that Windows won't create any more (I get NULL returned from AfxBeginThread). Including the 5 other threads in my program, Task Manager correctly reports that 61 threads are in use. I need 65.
Can I exceed this number in Windows 2000? Is there actually a limit on 61 threads per process?
Thank you
srs
|
|
|
|
|
I don't know with AfxBeginThread(), but I always use _beginthreadex() and have created more than 60 threads per processor...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Something else is going on. The theoretical limit is 2048 using default stack size. I would step into the MFC code and see what the problem is.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
The number of threads is limited by the amount of available virtual memory. By default each thread has one megabyte of stack space. This means that you can create at most 2028 threads. To obtain more threads you need to increase your virtual memory or reduce the stack size for each thread. See the CreateThread documentation for addition information.
|
|
|
|
|
What are the prefined control class names (WNDCLASS structures)? I can't find a list of them anywhere. Some I have figured out, EDIT, COMBOBOX, STATIC, BUTTON. But I need others as well, specifically the one for CDateTimeCtrl. Where can I get the list?
Ed
|
|
|
|
|