Passing lists to functions

This is a discussion on Passing lists to functions within the C Programming forums, part of the General Programming Boards category; First of all i would like to greet the forum,i just registered.Hope someday to be able to help here too,like ...

Passing lists to functions

First of all i would like to greet the forum,i just registered.Hope someday to be able to help here too,like you.

My assignment is about implementing a linked stack and a linked queue and my program should be able to enqueue-dequeue/push-pop,show and retrieve data from them (seperate operations for each).i have created all this using global variables to avoid double and triple pointers, but professor wants it with pointers.we are learning C this semester together with data structures,so i have zero experience with pointers.it took me days to write these 360 lines and i want it to be as it must be.i have noone to cooperate with,since i am the only one that had managed to do it...

my problem is passing lists to functions.this is the small part of my program ( enqueue a node to a linked queue) that i am working on to solve the problem,but i do not know what goes wrong with the pointers:

looking at it for days,never thought of using a pointer with a function.also the use of pointers in enqueue function make sense now.thank you very much for your time,you indirectly helped the whole class.i will go apply this to all the code.

A few problems:
* You entered the terminating 0 into the queue.
* You've ignored the rear pointer.
* You've created a stack, not a queue (i.e., following the "front" pointer prints out the input backwards).

system("pause") is a magical command that only compiles on my machine, apparently. What could it possibly do?. I assume you're joking. However, I should have removed it before posting.

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

I didn't realize this place was full of a bunch of unix snobs.
Goodbye.

Eh? Chill out. I'd describe this place as a pretty good mix. We are merely pointing out that a particular piece of code is nonstandard and won't work everywhere. Given that this board is C/C++ centric, not centric to any particular platform, this is not an unreasonable thing to do.

Some people (not pointing fingers) might seem rude from time to time. Maybe they are. Who cares. If you can't stand it, go ahead and leave. Otherwise take a pill and relax a little okay?

Perhaps you failed to notice that I said nothing about running the program, and that itCbitC's problem was about compiling the program. The system() function itself is in the standard library, under the <stdlib.h> header, but when adding that function call, you forgot to #include <stdlib.h> so you were relying on that header being included by another, which is not guaranteed. It is as simple as that.

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.