- #1
n1person
- 145
- 0
Oh noes! I wrote a code on my mac, it works fine, and then I move it onto my linux machine, it compiles fine (using g++ command), but then when i run it i get a "segmentation error." I've look around a bit online and I couldn't find anything which seems to fit this particular error. I can compile all my other programs fine.
(It is part of a larger program but I was able to isolate this code as problematic)
Thanks for your Help!
(It is part of a larger program but I was able to isolate this code as problematic)
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void)
{
int e;
e=1000; //number of elements in table
int k2;
k2=10;
float array[k2];
float error[k2];
float distance[k2];
float index[k2];
float narray[k2];
float nerror[k2];
float ndistance[k2];
FILE * inFileOne;
float f, p, q; // field1, field2, field3, field4, field5, field6;
inFileOne = fopen ("1.txt","r"); //file hard coded here
int i1;
float x1,x2,x3;
float x11[k2];
float x22[k2];
float x33[k2];
int count;
count=0;
for (i1=0; i1 <e+1; i1++) // test all lines
{
fscanf (inFileOne, "%f%f%f%f%f%f",&x1,&x2,&x3,&f,&p,&q);
if(p < 40)
{
x11[count] = x1;
x22[count] = x2;
x33[count]= x3;
index[count] = f; //Set variables for use to inputs
array[count] = p;
error[count] = q;
count=count+1;
}
else{}
}
}
Thanks for your Help!