I had gotten my code all working, and everything is capable of doing what it's supposed to do. The next step for me was to organize it a little better; re-allocating my definitions to different source code files and that such...and there the problem starts. After declaring three dyanamic link structures in the main source file, and then trying to pass them to another source file, I receive an error. The error actually points to a piece of known-working code, instead of in the actual passing; it seems to think that the things I have passed are no longer structs, but doubles. This code works completely fine if you declare them locally in the other source file, so red flags immediately go up for problems with passing.
I have not had any luck with this problem, and as far as I can tell (which, I'm a biologist, not a comp-sci =P), I have the correct syntax for passing the structures. Any help is HIGHLY appreciated, as this error code seems to be very non-prevalent on the web. I am using Visual C 2008 service pack 1, and I have specified that everything should forcefully be compiled as C code (and not C++). I have pasted my header file, my main source file, and the a portion of the source file that I am passing to.
The program errors on the last line of code that I have included of my source file that I'm passing to, which is "Push(&(Xtail->next), atof(mystring));"
The error code is: error C2223: left of '->next' must point to struct/union
=========Header===========
void ReadPDB(struct node** Xtail, struct node** Ytail, struct node** Ztail, struct node* Xlist, struct node* Ylist, struct node* Zlist);
void Push(struct node** headRef, double data);
struct node
{
double data;
struct node* next;
};
========Main Source File==========
#include <stdio.h>
#include <string.h>
#include "MoveRotateProtein.h"
int main()
{
char pressenter[5];
struct node Xlist; // Dynamic Link List of X coordinates; first link is blank.
struct node Ylist; // Dynamic Link List of Y coordinates; first link is blank.
struct node Zlist; // Dynamic Link List of Z coordinates; first link is blank.
struct node* Xtail = &Xlist; // pointer for X list
struct node* Ytail = &Ylist; // pointer for Y list
struct node* Ztail = &Zlist; // pointer for Z list
Xlist.next = NULL; //Initialize the structure
Ylist.next = NULL; //Initialize the structure
Zlist.next = NULL; //Initialize the structure
ReadPDB(&Xtail,&Ytail,&Ztail,&Xlist,&Ylist,&Zlist);
printf("Press enter when finished to end program.");
gets(pressenter);
return 0;
}
=========Beginning Portion of Source File Being Passed to============
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "MoveRotateProtein.h"
void ReadPDB(struct node** Xtail, struct node** Ytail, struct node** Ztail, struct node* Xlist, struct node* Ylist, struct node* Zlist)
{
FILE *fp;
int i = 0;
char mystring[100];
char tempstring[8];
do //Select the file to open, and ensure that the file selected exists; otherwise, try again
{
printf("Enter filename: ");
gets(mystring);
if((fp=fopen(mystring, "r"))==NULL) {printf("Cannot open file. Please try again.\n");}
}while((fp=fopen(mystring, "r"))==NULL);
//Fill DLL's with the X, Y, and Z coordinates of all of the biomolecule's atoms
while(strstr(fgets(mystring,100,fp),"ATOM 1 " )== NULL) {} //Parse lines until the start of the atom positions
fseek(fp ,-9,SEEK_CUR); //fgets fails to work completely as advertised, and this is needed to compensate for it
do //We're cued up and ready to read in all of the values. Now, go do it.
{
fseek(fp ,-53,SEEK_CUR);
fgets(mystring,9,fp); //I actually only want 8 characters, but fgets fails to work as it should, and only picks up 8
[B]Push(&(Xtail->next), atof(mystring)); //Read in & store the coordinate[/B]