0
I am Getting a *** stack smashing detected *** error, can someone help please?
Here is the code in c #include<stdio.h> #include<stdlib.h> struct point{ float x[2]; }; int main(int argc, char* argv[]){ struct point p[3]; for(int i=1; i<=8; i++) { if (argc > i) p[(i-1)/2].x[(i-1)%2]=atof(argv[i]); } for(int i=1; i<8; i++) { if((i%2)>0) printf("\n"); printf("%f ",p[(i-1)/2].x[(i-1)%2]); } printf("helo"); return 0; }
1 Antwort
+ 4
You declare an array of three struct points but try to access the .x member of the fourth element [(i-1)/2 = 3] if i is >=7