dequeue

This is a discussion on dequeue within the C Programming forums, part of the General Programming Boards category; the character value stores a name of user and the j stores his/her age. those two things stored in queue. ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    32

    dequeue

    the character value stores a name of user and the j stores his/her age.
    those two things stored in queue.
    I need to pop first data in queue and display them to the screen.
    but I can not figure out how to return two different types of values. Is there someway I can return Character value and interger?
    Code:
    char dequeue(struct queue *q)
    {
    	char name[25];
                    int i;
                   int j;
    	struct customer * tempPtr;
        
    	for(i=0; i<25; i++)
    	name[i] = q->front->firstname[i];
                     j = q->front->num;
    	tempPtr = q->front;
    
    	q->front = q->front->next;
    	if (q->front == NULL)
    		q->rear = NULL;
    	free (tempPtr);
    	return name;
    }
    Last edited by jk81; 11-27-2002 at 08:25 PM.

  2. #2
    ~- Y u n a -~ beely's Avatar
    Join Date
    Dec 2001
    Posts
    291
    you mean return char OR value into a variable? or char AND value into separated variable?

    char OR value into a variable
    > try declar the variable as character

    char AND value into separated variable
    > there's no any clue to return 2 value. but by using pointer you may fix this problem. for eg:

    Code:
    int main (void)
    {
    ..
    ..
    function (&char, &int);
    ..
    ..
    }
    
    void function (char *a, int *b)
    {
    ..
    ..
    printf ("enter character > ");
    scanf ("\n%c", &*a);
    ..
    printf ("enter integer > ");
    scanf ("\n%d", &*b);
    }

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    There are a bunch of ways to return more than one value, the best in this situation is to pass the address of the variables to the function and just change them:

    char dequeue ( struct queue *q, char *name, int *j );

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please check my C++
    By csonx_p in forum C++ Programming
    Replies: 263
    Last Post: 07-24-2008, 09:20 AM
  2. enqueue and dequeue pointer
    By cjwenigma in forum C++ Programming
    Replies: 8
    Last Post: 11-28-2007, 02:21 PM
  3. Dequeue
    By chuy in forum C Programming
    Replies: 7
    Last Post: 04-11-2006, 01:35 PM
  4. Prefix Evaluation
    By jcramer in forum C Programming
    Replies: 3
    Last Post: 04-19-2004, 12:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21