Take a quick step back; I'd like to suggest some general programming guidelines based on what I see from your code:
RECORD* insert (RECORD *it)
{
RECORD *cur, *q;
int num;
char junk;
char first[strsize];
printf("Enter a character:");
scanf("%c", &first);
cur=(RECORD *) malloc(sizeof(RECORD));
An insert()
routine on records suitable for complex datastructures is not usually expected / allowed / desired to perform user interaction; you are mingling user interface with internal business logic. (While business logic is a high-falutin phrase, I don't know a better way to say "the things your program has to do in order to justify its existence" or "the essential requirements the program must satisfy". Replacement suggestions welcomed. :)
Consider this pseudo-code as a replacement algorithm:
while we need more characters
prompt user for another character
store character in datastructure
print datastructure in reverse
Separate all the code for the datastructure from the interaction with the human. (This separation of presentation from logic is often formalized as
Model View Controller, but it is important to recognize that it is not limited to user interfaces -- you want your stack, list, or queue to be useful in your next programming project, so build generic routines that only operate on the stack, list, or queue, and you can reuse them in the next project.)
Update
Write a program that creates a linked
list of 10 characters, then creates a
copy of the list in reverse order. The
user should be prompted to input the
characters and the program should have
a print function that prints out the
original list and then prints out the
list in reverse order
Now this is more like it. While I appreciate what your teacher is trying to do, a linked list isn't the datastructure I'd select for this problem. (I would pick an array if the problem size was bounded, a stack if the problem size was unbounded.) It's solvable with a linked list, and there are three possible approaches that come to mind immediately:
Write a recursive output function that works like this:
void print_output(RECORD *r) {
if this is the last RECORD in the chain
print the data
else
print_output(next record in the chain)
}
This uses the call stack to reverse the output. Clever trick, but sometimes wastes memory compared to other approaches.
Write your lists with doubly-linked list elements. Use both next
and prev
pointers, and manage them all carefully to allow you to traverse the list in either direction. This requires subtle coding and carefully thinking things through. Or copying the correct order of operations from a published source such as Knuth or your favorite algorithms text. :)
Actually reverse your singly-linked list. Also requires subtle, careful coding or thoughtful copying. :)