I implemented queue in my code and I'm doing polling in my code. It's giving warning there. "assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast". Can anybody let me suggest where I'm mistaken.
#define QUEUE_SIZE 200
char buffer[100];
char queue[100] ; // queue implementaion
char Rear = - 1;
char Front = - 1;
/*enqueue start */
printf("3. code reached here \n");
if (buffer != NULL)
{
if (Rear == QUEUE_SIZE - 1)
printf("Overflow \n");
else
{
if (Front == - 1)
Front = 0;
Rear = Rear + 1;
queue[Rear] = buffer; // this line having above warning //
The type of queue[Rear]
is a char
and the type of buffer
is char [100]
. If you want to copy the first element it would be:
queue[Rear] = *queue;
If you want to you copy a range you would use memcpy()
. As queue
and buffer
are the same size you have to be mindful about buffer overflow:
memcpy(&queue[Rear], buffer, sizeof queue - Rear);