struct listNode
{
double xdata;
double ydata;
double zdata;
struct listNode * nextPtr;
};
typedef struct listNode LISTNODE;
typedef LISTNODE * LISTNODEPTR;
void insert(LISTNODEPTR *sPtr,double xvalue,double yvalue,double zvalue)
{
LISTNODEPTR newPtr,previousPtr,currentPtr;
newPtr=(struct listNode *)malloc(sizeof(LISTNODE));
if(newPtr!=NULL)
{
newPtr->xdata=xvalue;
newPtr->ydata=yvalue;
newPtr->zdata=zvalue;
newPtr->nextPtr=NULL;
previousPtr=NULL;
currentPtr=*sPtr;
while(currentPtr!=NULL)
{
previousPtr=currentPtr;
currentPtr=currentPtr->nextPtr;
}
if(previousPtr==NULL)
{
newPtr->nextPtr=*sPtr;
*sPtr=newPtr;
}
else
{
previousPtr->nextPtr=newPtr;
newPtr->nextPtr=currentPtr;
}
}
//else
//printf("%d not inserted. no memory available.\n",xvalue,yvalue,zvalue);
}
如何将x,y,z存入文件中,并且保证他们各自为一列?
谢谢