I'm getting a segmentation fault with this piece of code. I pretty sure it has something to do with my use of sscanf(). Any tips would be greatly appreciated.
Code:
char c;
.
.
.
.
if(argc==ARGNUM)
{
input = atoi(argv[2]);
tempmol1 = molecule[input];
input = atoi(argv[3]);
tempmol2 = molecule[input];
input = atoi(argv[4]);
cellshift.X = input;
input = atoi(argv[5]);
cellshift.Y = input;
input = atoi(argv[6]);
cellshift.Z = input;
check = 1;
while(sscanf(argv[1][i],"%[^.]",&c)&&check!=0)
{
if(c=='\0') check = 0;
i++;
}
for(j=0;j<3&&check==1;j++,i++)
{
if(argv[1][j]!=extension[j]||argv[1][j]=='\0') check = 0;
}
if(!check)
{
message("Warning! file could not be opened. Default file will be loaded");
//file = "default.cif";
}
fin = fopen(argv[1],"r");
if(!fin) error("cannot read %s",argv[1]);
}
let me know if you can catch the problem here.
THANKS