If you would use the debugger you would quickly see what's wrong. You should really get acquainted to use it.
What I can see in your code is that you don't update
consequently. For example: What does
point to in an empty queue? Probably NULL, I assume. So what happens in
when you are inserting the first element? You are using the
pointer (which is null) and do:
rear->Next = temp;
which will produce undefined results. Similarly in
: What happens when you remove the last element? In that case
should be set to NULL. I don't see that in your code. So again you are provoking undefined behavior.