Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C++ program stack fault at module?

Status
Not open for further replies.

Rthreed

Newbie level 1
Newbie level 1
Joined
Feb 3, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
I am a beginner at c++ and i was trying to make this dice in a matrix that would show 1 exactly on the positions where a real dice has its dots and 0 in rest. Can someone help me by telling me why is it giving me this error when i run it. I would really appriciate it.

#include<iostream.h>
#include<stdlib.h>
#include<stdio.h>
int i,j,t,w,a[6][6];

struct zar
{
int x1,y1,x2,y2;
};

zar x,y,z,k;

int rand()
{

w=random(3)+1;


while (w>=1)

{

t=random(4)+1;

if (t==1)
{
a[x.x1][x.y1]=1;
a[x.x2][x.y2]=1;
}
else if (t==2 && a[1][1]==1)
{
a[y.x1][y.y1]=1;
a[y.x2][y.y2]=1;
}
else if (t==3 && a[1][1]==1 && a[3][1]==1)
{
a[z.x1][z.y1]=1;
a[z.x2][z.y2]=1;
}
else if (t==4 && a[2][1]==0)

a[k.x1][k.y1]=1;

w--;

}

return a[j];
}


void main ()

{

x.x1=1;
x.y1=1;
x.x2=3;
x.y2=3;
y.x1=1;
y.y1=3;
y.x2=3;
y.y2=1;
z.x1=2;
z.y1=1;
z.x2=2;
z.y2=3;
k.x1=2;
k.y1=2;
k.x2=0;
k.y2=0;

for (i=1;i<=3;i++)
for (j=1;j<=3;j++)
a[j]=0;

cout<<rand()<<" ";
cout<<endl;
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top