Alright, this function is in a thread which is reading lines from a file which will never be longer than 16 chars. inside the while(1) loop, if I comment out everything except an output of ptrr and the fgets, there is no seg fault. Also, I can comment out the push_backs and I still get the seg fault. Can someone please help me figure this one out?
Code:
void * read_file(void*){
FILE * oar1 ;
oar1 = fopen("/dev/ttyT8S0","r");
char *ptrr = new char[16] ;
char *index = new char[16] ;
char *value = new char[16] ;
long ind = 0 ;
long vl = 0 ;
while(1){
fgets(ptrr, 16, oar1);
if(atoi(ptrr)!=0){
index = strtok(ptrr,",");
value = strtok(NULL,", ");
ind = strtol(index,NULL,16); vl = strtol(value,NULL,16);
identifier.push_back(ind);
vals.push_back(vl);
cout<<ind<<" - "<<vl<<endl;
}
}
fclose(oar1);
}