В этой C-программе мне нужно было создать очередь с использованием структурированного подхода. Когда я пытался запустить эту программу в NetBeans, я увидел, что получаю усеченную ошибку перемещения. Мой профессор сказал мне запустить его в Клионе, и я все еще получаю ту же самую ошибку. В частности, ошибка указывает на то, что у меня есть неопределенная ссылка на 'dequeue', 'enqueue' и 'getCurrentSize'.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value);
void dequeue(int** queue, int* size);
int getCurrentSize(int size);
void display(int* intQueue, int size);
int main()
{
int input;
int initSize = 3;
int size = 0;
char option = 'a';
char answer = 'y';
int value;
bool enqueueResult, dequeueResult = true;
int* queue = (int*)malloc(initSize * sizeof(int));
for (int i = 0; i<initSize; i++)
queue[i] = 0;
printf("This program implements Queues using structured programming. Enter "
"a number from 1 to 4 . \n"
"1. To enqueue a number \n"
"2. To dequeue a number \n"
"3. To get the current size of the queue \n"
"4. To see the contents within the queue \n"
"5. Exit the program");
scanf("%d", &input);
switch (input)
{
case 1:
enqueueResult = enqueue(&queue, &size, value);
if (enqueueResult == true)
printf("The number has been put into the queue!");
else
printf("The number was not able to be enqueued!");
break;
case 2:
dequeue(&queue, &size);
printf("Number was dequeued from the queue");
break;
case 3:
printf("The current size of the queue is: " + getCurrentSize(size));
break;
}
free(queue);
return 0;
}
//********************************************************
//QueueLibrary.c below
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value)
{
int maxSize = *size + 1;
if (*queue == NULL)
return false;
if (*size < 0)
return false;
if (*size == maxSize)
{
int* copy = (int*)malloc((maxSize + 1) * sizeof(int));
if (copy == NULL)
return false;
maxSize += 1;
for (int i = 0; i < *size; i++)
copy[i] = (*queue)[i];
free(*queue);
*queue = copy;
}
for (int i = *size; i > *size - 1; i--)
{
(*queue)[i] = value;
printf("The value %d has been added to the queue\n", (*queue)[i]);
}
*size += 1;
return true;
}
void dequeue(int** intQueue, int* size)
{
printf("%d has left the queue\n", *intQueue[0]);
for (int i = 0; i < *size; i++)
(*intQueue)[i] = (*intQueue)[i + 1];
if (*size != 0)
*size -= 1;
else
printf("There is nothing left in the queue\n");
}
int getCurrentSize(int size)
{
return size;
}
void display(int* intQueue, int size)
{
printf("The integers in the queue are :\n");
for (int i = 0; i < size; i++)
printf("%d\n", intQueue[i]);
}
Это сообщение об ошибке