|
yes I know it, but it strange that at time debugig there is no errors, I opened all list of errors, and there is nothing.
And my project with debug works correctly, it's strange that it's a problem at time opening exe file
|
|
|
|
|
Not strange at all; this is a fairly common occurrence. You need to add some code to the program to identify why this value goes out of range at some time.
Use the best guess
|
|
|
|
|
|
Member 10072694 wrote: but I can compile without debuging or I can debug it, and there is no problem; it works correctly: Negative. Assertions do not fire in release mode, only debug mode. The problem still exists.
You have a list that you are trying to access, so what does that code look like?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
There is also an easy way this comes about
In debug mode the compiler will zero all variables and memory in release mode it doesn't the memory will have garbage in it.
Are the index variable been zero or set to a specific value or are you just assuming it is?
|
|
|
|
|
leon de boer wrote: Are the index variable been zero or set to a specific value... I would have no way of knowing.
leon de boer wrote: ...or are you just assuming it is? I'm not assuming anything.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Here let me show you
void silly_error_code (int j){
const char somearray[5] = {'0','1','2','3','4'};
char testval;
testval = somearray[j];
}
int i;
main {
silly_error_code(i);
}
That code will work fine in debug mode but will most likely crash with the sort of error you have in release mode and the compiler won't pick the error.
WHY ... because variable global variable "i" was never set to any value
When you run in debug mode the compiler zeros all global variables there is a long story of why it does that but for now all you need to do is that it does.
So in debug mode testval will always come back with "0" because i is initialized by the debug mode to 0
In release mode it is highly likely this will crash as "i" could be any value including values which are way outside the array range of somearray.
See how the code above has the same problem as your code ... I can use it safely in debug mode BUT not release.
MICROSOFT TIP: Variables and allocated memory are often initialized differently in Debug versions than in Release version of software. If you've assumed that your variables are zeroed when they are declared could easily cause strange behavior in Release mode on Win9x. You can also introduce bugs that are Win9x specific. WinNT, for security reasons, zeros all memory before it is used.
modified 13-Aug-13 16:12pm.
|
|
|
|
|
leon de boer wrote: That code will work fine in debug mode but will most likely crash with the sortof error you have in release mode and the compiler won't pick the error.
WHY ... because variable global variable "i" was never set to any value
When you run in debug mode the compiler zeros all global variables there is a long story of why it does that but for now all you need to do is that it does. So in debug mode testval will always come back with "0" because i is initialized by the debug mode to 0 In release mode it is highly likely this will crash as "i" could be any value including values which are way outside the array range of somearray. I am fully aware of this.
leon de boer wrote: See how the code above has the same problem as your code... My code?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
thank you all for information,
but in realise mode I have "debug error", and it's like that it can't debug my project ????????
|
|
|
|
|
Mkhitar_Sargsyan wrote: but in realise mode I have "debug error", and it's like that it can't debug my project ???????? You've been instructed no less than a half dozen times how to fix it.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
thank you very much
I found out it.
it occurred that's why exe file gets its values from another file, where debug wrote nothing
|
|
|
|
|
Hi All
I want to write a program in C++ to get hash key of windows account's password .
thank for any help or refrence
|
|
|
|
|
OK, go ahead and write it. But don't expect anyone here to help you break through security.
Use the best guess
|
|
|
|
|
I supprised when I see this :
"break through security" , it is not true!!!
|
|
|
|
|
Then please explain exactly what you are trying to do.
Use the best guess
|
|
|
|
|
|
it is good , but it works offline!
I want to write a program that get the hash key , when windows is boot
|
|
|
|
|
#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
/* here array board[][] is declared to be a global variable*/
int board[9][9];
/* this function returns a random number in the specified range(excluding the upper limit)
in this program,returns random number between 0 and 8 */
int randrange(int low,int high)
{
return rand()%(high-low)+low;
}
bool check(int num,int row,int col)
{
int i;
// checks if number is repeated in that row or not
for(i=0;i<9;i++)
{
if(board[row][i]==num)
{
return false;
}
}
// checks if number is repeated in that column or not
for(i=0;i<9;i++)
{
if(board[i][col]==num)
{
return false;
}
}
return true;
}
/* this function checks if that particular element in the array 'board' is already assigned
a value or not */
bool non_empty(int row,int col)
{
//0 is default value
if(board[row][col]==0)
return true;
// true indicates unassigned element
else return false;
// false indicates an element which is already assigned a value
}
// a class handiling all the inintialisation part of the board
class initialisation
{
private:
int num,i,j,row,col;
bool flag=true;
public:
void _initialisation();
void display();
};
void initialisation::_initialisation()
{
// in the for loop below ,numbers from 1 to 9 are assigned to the array board[][]
//the row and column index are chosen at random
for(num=1;num<=9;num++)
{
flag=true;
for(i=0;i<9;i++)
{
do
{
row=randrange(0,9);
col=randrange(0,9);
/* in this if statement we perform calls to two functions
non_empty(row,col) returns true only if that element in the
array board is not assigned a value earlier,if not returns false.
check(num,row,col) returns true only if that particular number 'num' is not
repeated in that row and column */
if(non_empty(row,col)&&(check(num,row,col)==true))
{
flag=true;
board[row][col]=num;
}
else
flag=false;
} while(flag==false);
}
}
}
//this method displays the elements in array board[][]
void initialisation::display()
{
for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
cout<
|
|
|
|
|
1. Actually ask a question.
2. Use code tags when posting code.
< p r e> //without the spaces
your code
< / p r e> //without the spaces
|
|
|
|
|
I notice that you don't have any graphics code.
Is this a DirectX question ???
Show us your drawing code.
|
|
|
|
|
So what do you see when single-stepping through the code using the debugger? What is board being populated with? This is not to be confused with what you want it to be populated with. What are non_empty() and check() returning?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 13-Aug-13 10:46am.
|
|
|
|
|
The problem of your code (excluding minor fixes) is that the filling algorithm is probably wrong (it cannot complete the board). I suppose you should apply a backtracking algorithm.
Veni, vidi, vici.
|
|
|
|
|
Hello guys. I have this example which uses a design pattern. I don't know which design pattern is this.
I have this ClassMain , ClassParent , ClassChildOne and ClassChildTwo . ClassMain contains an array of type ClassParent, and stores the references of the two derived classes. Here is it how do I do it.
class CClassMain
{
#define MAX_COUNT 2
CClassParent arrParent[MAX_COUNT];
public void AddRef(CClassParent* ptr, int nIndex)
{
arrParent[nIndex] = ptr;
}
}
class CClassParent
{
static CClassMain* ptrMain;
public CClassParent() { ptrMain = new CClassMain;}
public void AddRef(int nIndex) {
ptrMain->AddRef(this, nIndex)
}
}
class CClassChildOne : CClassParent
{
public CClassChildOne
{
CClassParent::AddRef(1);
}
}
class CClassChildTwo : CClassParent
{
public CClassChildTwo()
{
CClassParent::AddRef(2);
}
}
The design pattern states that if I have to add new functionality (classes), it is really is easy now. I will simply increase the MAX_COUNT in CClassMain and derive the newly added class from CClassParent .
So what is the name of this design pattern and how do I study more about it specifically (and design patterns in general). Thanks for any info.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
|
I wouldn't say this to be the clean version of any of the popular patterns and without the context (sorrounding code) I would say this code isn't designed well and overcomplicated for no reason. This is typical among programmers who learn programming by reading pattern books. Many of the best programmers I know learnt programming without any patterns. By becoming a good programmer you instinctly find out and start using some patterns wihtout actually knowing the pattern and/or its name. I don't say its a bad thing to learn about patterns but trying to use them as golden hammers like many pattern-learners do is ridiculous. A programmer can be a very good programmer without knowledge of patterns and another one can be terribly bad coder with a lot of pattern knowledge. Knowing the patterns is good only when it comes to communication between programmers, its easier to say "visitor pattern" then describing how would you build up the classes and how would you call their methods... Don't overuse them, you become a better programmer if you try solving problems with simple methods and its OK to find it out later that your solution is very similar to one of the patterns. I've already worked on some codebases created by pattern magicians. This kind of terrible work can be one of the hardest to understand bloatcode on earth.
|
|
|
|