type nodetype=record num:integer;p:^nodetype;end;
var head,now:nodetype
begin
new(head);
now:=head
readln(now^.num);
new(now^.p);
now:=now^.p;
...
...
...
/*
The following function will create a List,
and need to enter data!
*/
int CreateList ()
{
char ch;
struct ListCharacter *NewNode;
/*
Tips!
*/
printf ("\n\n\n\n\nDirect:");
printf ("\n Please press a character to add to the List,");
printf ("\n or press the ENTER key to output the reverse List!");
ch=getch ();
while (ch!=13)
{
/*
Create new node for List!
*/
NewNode=(struct ListCharacter *) malloc (sizeof (struct ListCharacter));
NewNode->Character=ch;
NewNode->Next=NULL;
printf ("%c",ch);
/*
This part will create the List!
*/
if (Head==NULL)
Head=NewNode;
else
This->Next=NewNode;
This=NewNode;
ch=getch ();
/*
Loop create List!
*/
}
/*
Information:
There may be some errors:
The following sentences will cause some errors in Microsoft Visual
C++ 6.0 Complier.
The execute file produced by Microsoft Visual C++ 6.0 may also cause a
general protect error!
But,Borland Turbo C 2.0 complier will not occur!
Why?
when conner presses "ENTER" key without pressing any other key before!
The value of "Head->Character" will be unsureness!
The pointer points to a unknow memory area!
The default value of "Head->Character" is Enter(ASCII 13).
The solution of the problems above can be:
*/
if (Head==NULL) Head->Character =ch;
return (1);
}
/*