You said that NUM_PRICES is declared as 3 so prices[3] is past the array-boundsOriginally Posted by bazzano
Kurt
You said that NUM_PRICES is declared as 3 so prices[3] is past the array-boundsOriginally Posted by bazzano
Kurt
but if i say that prices[3] how am i goin past the array bounds when dollars=0
There are only 3 prices.
prices[3] is the 4th.
Kurt
when u say prices[3]. three array elements are declared of type struct .... where elem1 is refrences by prices[0] all array elements starts from 0. so when u say prices[3]. three elements are declared prices[0], prices[1], prices[2]. when u say prices[3] it is out of boundary and when accessing the dollor which u cant do will get u SEGFAULT
ssharish2005
If you declared prices as prices[3] There would be something in prices[0], prices[1], and prices[2]. The counting starts at 0 not 1. So anything beyond prices[2] gets you a seg fault.
~Sven
Windows XP Home Edition - Dev-C++ 4.9.9.2
board.theprogrammingsite.comOriginally Posted by "The C Programming Language" by Brian W. Kernignhan and Dennis M. Ritchie
Yet another programmer who doesn't know how to count from 0...
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}
prices[somenumberhere] is not a pointer array of type PriceType; its just a normal array. -> is used when access the struct data members using pointer. as its a normal array u need to access the data members uisng . operator.
i am suprised dint the compiler give any error about thus telling "invalid type argument of â->â
"
ssharish2005