Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing a pointer to an array in a struct

Tags:

c

What's wrong in my function 'front'? I want to pass the pointer to an specific line in my array to read/edit it.

struct queue
{  
  char itens[LN][CL];
  int front,rear;
}; 


char *front(struct queue * pq)
{
  return pq->itens[pq->front+1][0];
}
like image 824
kreis Avatar asked Dec 16 '22 09:12

kreis


1 Answers

You're currently returning a single char, not a pointer to a row. Take off the [0]:

char *front(struct queue *pq)
{
    return pq->itens[pq->front+1];
}
like image 199
Carl Norum Avatar answered Jan 04 '23 14:01

Carl Norum