That better include
learning to understand the terms, if you actually want to communicate with people. Also, if you understand the concept, it is easy to use the term referring to it. People who claim to "understand but not know the words" usually in fact misunderstand and may fool themselves by believing they "just do not know the words".
Terminology is important, and it is about words and the meaning of words. For example, the difference between the
declaration,
definition, and
initialization of a variable has a specific technical meaning that you will need to understand if you want to succeed at C programming. Hands-on (you use the term "through application") coding is a lot about words and meaning anyway (notice that we use
languages made up, in part, of
keywords. Not keynumbers or keyicons or keyideas). If you are resistant to wordage and language use you will not enjoy programming or get far with it.
I am sure we all at least occasionally end up over our heads WRT terminology, and I know that when you first start with C and programming there are
a lot of new terms everywhere, some cryptic and some innocuous. You
need to learn them, or you will remain lost. Fortunately, words are the prime medium of human communication, so when you find one you do not understand, there are a number of ready available methods for you to deal with your problem.
1) Look up the term on-line. If you google "C programming [word]" you will get material. Wikipedia is a good source for general programming terms, a lot of words there are disambiguated into separate articles to do specifically with computing.
2) If after that you are still not satisfied with your understanding,
ask a direct question. Do not be shy. "What does [word] mean?" is straightforward and you will get at least some straightforward answers
Fair enough? I'm not just saying that because l'm long-winded, lol. I'm saying it because it is important. I've highlighted in green some important words/terms below. Be sure you know what they mean.
Lets have a look at a couple of things that jump out right away in that code:
Main() returns an int, whether you like it or not. This is not a serious issue in your program, but if you do not respect this convention you will hear the same thing over and over until you do. Since main() returns an int, you must do so in your code. Ie, a skeletal main() is:
Code:
int main(void) {
return 0;
}
More serious is this:
Code:
for(x=0; x<5; x++)
{
void(Serve);
printf("Data Deleted");
}
That is not how to call a function in C. I think what you want is:
Code:
Serve(Head, Tail, i);
This is still not going to fix a design flaw in the code, namely that the user can choose either 1 or 2, then the program ends. If I choose 2, there is no data to delete anyway.
But first things first.
Code:
void Serve(QueuePointer *Head, QueuePointer *Tail, int *item)
{
QueuePointer Temp;
Temp=(QueuePointer)malloc(sizeof(struct Node));
if (Head == NULL)
printf("Queue is empty. Cannot delete");
else
{
item->Head=Data;
Temp=Head;
You are treating an int
pointer as if it were a pointer to a struct, and (further...) AFAICT you have no struct with a
member "Head". You do have one with a member Data. But you do not have any
variable named Data, so that is an assignment with an invalid
right hand side (item->Head) and an invalid
left hand side (Data).
I suspect that you have gotten a little ahead of yourself with C, and are trying to modify/copy some existing code you've found (perhaps a tutorial), but without actually understanding the original. That's kind of a viscous circle, lol. I think you might want to try some simpler things until you understand basics better before you try to implement a queue. $0.02. If you want to keep going with this anyway, correct the things I've pointed out. Methinks they are certainly not the only problems, but they are a start.
Finally, your indenting is very screwy. Have a look at this:
Indent style - Wikipedia, the free encyclopedia
Choose one of the styles there and imitate it.
PLEASE. For your own good.