Hello,
I am trying to use an if statement which has a pointer in it to determine which function to use.
The original code would be -
Code:
pqueue *pq = new_bounded_pqueue(5,le_artist);
I want to use an if statement so if a user inputs a certain variable it will declare a different line of code. Here is what I have done so far -
Code:
printf("Please enter if you want to order by ascending or descending, A = Assending, D = Descending: \n"); scanf("%c", &order);
pqueue *pq;
if (order == 'A' || order == 'a') {
pqueue *pq = new_bounded_pqueue(5,le_artist);
}
else if (order == 'D' || order == 'd')
{
pqueue *pq = new_bounded_pqueue(5,le_artistdec);
}
Once compiled the program runs but as soon as I input data I return a segmentation fault.