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]

>>fgets fails to work completely as advertised,
Nope -- it has been working correctly for millions of programmers all over the world during the past 25 years. If there was a bug in fgets() then it would have been found and corrected years ago. The problem is in your program, not in fgets().

>>fgets(mystring,9,fp); //I actually only want 8 characters, but fgets fails to work as it should, and only picks up 8

You declared mystring too small. If you want 8 characters in it then you have to declare the string to be at least 10 characters. fgets() may or may not append '\n' to the end of the string, depending on if '\n' is encountered in the file. It also appends the NULL string terminating character.

When dealing with character arrays its better to declare the array too big then too small. If you are going to err, then make it on the generious side.

>>fgets fails to work completely as advertised,
Nope -- it has been working correctly for millions of programmers all over the world during the past 25 years. If there was a bug in fgets() then it would have been found and corrected years ago. The problem is in your program, not in fgets().

Haha. I know =P. I was mostly annoyed with it earlier on today because I had to back up about 8 or 9 lines in order to get the ball rolling for everything else...and I couldn't figure why. But, I don't suspect that this issue has anything to do with my problem at all.

And, thanks for editing my post! I'll read up on the faq a little better before I do so next time.

-Ryan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.