435,190 Members | 1,056 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,190 IT Pros & Developers. It's quick & easy.

access violation??

 P: 4 hi i'm getting access violation to my code.. what might be the problem?? plz help me... //my code... #include void main() { int prneqldrn(int a[],int b[]); int tmp; int c[]={1,1,1,1,0,0,1,0,0,1,0,1,0,0,1,1,1,0}; int d[]={1,1,1,1,0,0,0,1,0,1,0,1}; tmp=prneqldrn(c,d); //printf("%d",tmp); } int prneqldrn(int datain[],int presntadd[]) { int prn_t, drn_t; int i,j,temp,t; for (i=6;i<=9;i++) { j=i-6; drn_t[j] = datain [i]; } for (i=6;i<=9;i++) { j=i-6; prn_t[j] = presntadd[i]; } for(i=0;i<=3;i++) { temp[i]=(drn_t[i]==prn_t[i])?1:0; } t=(temp&temp&temp&temp); return t; } Jun 13 '07 #1
6 Replies

 100+ P: 208 hi i'm getting access violation to my code.. what might be the problem?? plz help me... //my code... Expand|Select|Wrap|Line Numbers #include void main() {     int prneqldrn(int a[],int b[]);     int tmp;     int c[]={1,1,1,1,0,0,1,0,0,1,0,1,0,0,1,1,1,0};     int d[]={1,1,1,1,0,0,0,1,0,1,0,1};     tmp=prneqldrn(c,d);     //printf("%d",tmp);     }     int prneqldrn(int datain[],int presntadd[]) {       int prn_t, drn_t;     int i,j,temp,t;       for (i=6;i<=9;i++)         {             j=i-6;             drn_t[j] = datain [i];         }     for (i=6;i<=9;i++)     {         j=i-6;         prn_t[j] = presntadd[i];     }     for(i=0;i<=3;i++)     {         temp[i]=(drn_t[i]==prn_t[i])?1:0;     }     t=(temp&temp&temp&temp);       return t; } Firstly Please enclose your code in [code] [/ CODE] brackets Second. When I run this I don't get any access violation errors. The function returns 0. Jun 13 '07 #2

 P: 94 if you comment out this -> Expand|Select|Wrap|Line Numbers t=(temp&temp&temp&temp); then it compiles Go look at that Jun 13 '07 #3

 P: 4 Firstly Please enclose your code in [code] [/ CODE] brackets Second. When I run this I don't get any access violation errors. The function returns 0. hi, thanq for ur quick response... i tried the compilation in turboc++.it worked well without any problem.. but in vc++ its giving problem... someone told it is b'coz of the s/w (vc++) which has n't been installed properly.... anyway thanx a lot.. Jun 13 '07 #4

 P: 4 if you comment out this -> Expand|Select|Wrap|Line Numbers t=(temp&temp&temp&temp); then it compiles Go look at that hi, thanq for ur quick response... i tried the compilation in turboc++.it worked well without any problem.. but in vc++ its giving problem... someone told it is b'coz of the s/w (vc++) which has n't been installed properly.... anyway thanx a lot.. Jun 13 '07 #5

 Expert Mod 5K+ P: 9,197 Here's part of your problem: Expand|Select|Wrap|Line Numbers prneqldrn(int datain[],int presntadd[]) {   int prn_t, drn_t; int i,j,temp,t;   for (i=6;i<=9;i++) { j=i-6; drn_t[j] = datain [i];     <------ } etc...   drn_t is an array of 3 elements. drn_t[j] cannot be larger than 2. Otherwise, you get your error. i = 6 then j = 0 i = 7 then j = 1 i = 8 then j = 2 i = 9 then j = 3 < BOOM! Jun 13 '07 #6

 P: 4 ya ... u r correct.. i've changed that one and i got the output... Jun 14 '07 #7 