/*Write a program that creates a link list of 10 characters,
then creates a copy of the list in reverse order*/
#include <stdlib.h>
#include <stdio.h>
// self-referential structure
struct linkList_data
{
char data; //each listNode contains a character
struct linkList_data *nextPtr; //pointer to next node
}; //end structure linkList_data
char linkList_dataPtr, *sPtr;
char value;
char newPtr; // pointer to new node
char previousPtr; // pointer to previous node in list
char currentPtr; // pointer to current node in list
linkList_data;
int main ()
{
newPtr = malloc( sizeof( linkList_data ) ); //create node
if ( newPtr != NULL ) //is space available
{
newPtr -> data = value; // place value in node
newPtr -> nextPtr = NULL; //node does not link to another node
previousPtr = NULL;
currentPtr = *sPtr;
// loop to find the correct location in the list
while ( currentPtr != NULL && value > currentPtr->data )
{
previousPtr = currentPtr; /* walk to ... */
currentPtr = currentPtr->nextPtr; /* ... next node */
} // end while
// insert new node at beginning of list
if ( previousPtr == NULL )
{
newPtr -> nextPtr = *sPtr;
*sPtr = newPtr;
} //end if
else //insert new node between previousPtr and currentPtr
{
previousPtr -> nextPtr = newPtr;
newPtr -> nextPtr = currentPtr;
} //end else
} //end if
else
{
printf( "%c not inserted. No memory available.\n", value );
} // end else
getchar ();
return 0;
} //end main
When i run the program i get 3 errors "cannot convert 'void *' to 'char'", "Declaration terminated incrrectly" and "Pointer to structure required on left side of -> or ->*" the last 1 i got about 6 times. what can be wrong with it?
Please help!!!!
Thank you.

New Topic/Question
Reply




MultiQuote





|