Code:
void find(int numbertofind)
{ int number1, type, number2, type2, number3, type3, length, length2, length3;
int cont2, cont3, cont;
double x, y, z, x2, x3, y2, y3, z2, z3;
FILE *data_file2;
data_file2 = std::fopen("positions_hook23_e5_polymers", "r");
while(fscanf(data_file2, "%d %d %lf %lf %lf %d %d\n", &number1, &type, &x, &y, &z, &length, &cont)!= EOF)
{fscanf(data_file2, "%d %d %lf %lf %lf %d %d\n", &number2, &type2, &x2, &y2, &z2, &length2, &cont2);
fscanf(data_file2, "%d %d %lf %lf %lf %d %d\n", &number3, &type3, &x3, &y3, &z3, &length3, &cont3);
if (used[number3]==0){
if (number1 == numbertofind){
fprintf(output_file2,"%d %d %lf %lf %lf %d %d\n", number1, type, x, y, z, length, cont);
fprintf(output_file2,"%d %d %lf %lf %lf %d %d\n", number2, type2, x2, y2, z2, length2, cont2);
fprintf(output_file2,"%d %d %lf %lf %lf %d %d\n", number3, type3, x3, y3, z3, length3, cont3);
used[number3]==1;
if(cont2>1){find(number2);}
}
if (number2 == numbertofind){
fprintf(output_file2,"%d %d %lf %lf %lf %d %d\n", number1, type, x, y, z, length, cont);
fprintf(output_file2,"%d %d %lf %lf %lf %d %d\n", number2, type2, x2, y2, z2, length2, cont2);
fprintf(output_file2,"%d %d %lf %lf %lf %d %d\n", number3, type3, x3, y3, z3, length3, cont3);
used[number3]==1;
if(cont>1){find(number1);}
}
}
}
fclose(data_file2);