Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8831571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:20:23+00:00 2026-06-14T08:20:23+00:00

I am getting an error from GCC when trying to compile this code. test.c:

  • 0

I am getting an error from GCC when trying to compile this code.

test.c: At top level:
test.c:35: error: conflicting types for âprintCoursesâ
test.c:4: error: previous declaration of âprintCoursesâ was here
test.c:59: error: conflicting types for âidSortâ
test.c:5: error: previous declaration of âidSortâ was here
test.c:100: error: conflicting types for âcourseSortâ
test.c:6: error: previous declaration of âcourseSortâ was here
test.c:137:2: warning: no newline at end of file

That is the error I am getting if anyone could please help. I am trying to organize a structure array (WITHOUT using qsort) and then sort it again using a different parameter. Here is my code:

#include <stdio.h>
#include <string.h>

void printCourses(struct courses *classList, int left, int size);
void idSort(struct courses *classList, int left, int right);
void courseSort(struct courses *classList, int left, int right);

//STRUCTURE 

struct courses
{
char course[50];
char courseName[50];
int courseID;
};

//MAIN

int main(void)
{
    int a, b,temp,i;
    int size = 11;
    struct courses classList[11]={{"MATH", "Linear Algebra", 3330},{"CSE", "Discrete         
    Structures", 2315},{"CSE","Intermediate Programming",1320},{"IE","Engineering Economics",  3312},{"CSE","Computer Organization", 2312},
    {"MATH","Calculus I",1426},{"CSE","Introductory Programming", 1310},{"MATH","Calculus II", 2425},{"IE","Engineering Statistics",3301},{"CSE","Operating Systems", 3320},{"CSE","Data Structures and Algorithms", 2320}};

    courseSort(classList, 0, size-1);
    printCourses(classList, 0, size-5);
}

//FUNCTION 1

void printCourses(struct courses *classList, int left, int size)
{
     int l,r;
     if( left < size)
     {
         l = left;

         printf("%s\n",classList[left].course);
         printf("------------------------------------\n");
         while( l < size )
         {
             printf("%d %s\n",classList[l].courseID,classList[l].courseName);
             l++;
         }

         printCourses(classList,left+6,size+2);
         printCourses(classList,left+8,size+5);
    }

}


//FUNCTION 2

void idSort(struct courses *classList, int left, int right)
{

  int pivot, l, r, comp, comp1;
  struct courses temp;
  if(left < right) 
  {
    pivot = left; 
    l = left;
    r = right;
    while(l < r) 
{

    while(classList[l].courseID <= classList[pivot].courseID && l <= right)

            l++;

    while(classList[r].courseID > classList[pivot].courseID && r >= left)

            r--;

  if(l < r ) 
  {
      temp = classList[l];
      classList[l] = classList[r];
      classList[r] = temp;
  }
}


temp = classList[r];
classList[r] = classList[pivot];
classList[pivot] = temp;

idSort(classList, left, r-1);
idSort(classList, r+1, right);
  }
}

//FUNCTION 3

void courseSort(struct courses *classList, int left, int right)
{
  int pivot, l, r, comp, comp1;
  struct courses temp;
  if(left < right) 
  {
    pivot = left; 
    l = left;
    r = right;

    while(l < r) 
    {

    while(strcmp(classList[l].course, classList[pivot].course) <= 0 && l <= right)
            l++;
    while(strcmp(classList[r].course, classList[pivot].course) > 0 && r > left)
            r--;

  if (l < r)
  {
      temp = classList[l];
      classList[l] = classList[r];
      classList[r] = temp;
  }
}


temp = classList[r];
classList[r] = classList[pivot];
classList[pivot] = temp;

courseSort(classList, left, r-1);
courseSort(classList, r+1, right);

}
idSort(classList,left,right-5);
idSort(classList,left+6,right-3);
idSort(classList,left+8,right-1);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:20:24+00:00Added an answer on June 14, 2026 at 8:20 am
    1. Always solve the first error you are getting. This is definitelly not the first error.
    2. At the point where you declare your functions, struct courses doesn’t exist yet. That’s why you are getting this error.

    Either add forward declaration or move the structure definition before the function declarations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile some code for the iphone simulator but am getting this
I'm trying to compile this piece of code from the book The C Programming
I am getting this error from eway token payment API, soap:ReceiverServer was unable to
I am getting this error from time to time with serialization and I don't
I am getting an error from a piece of code. I will only show
I am getting a compile error from the following property. The error is: The
I'm using asynchat and trying to use python3. getting this error: error: uncaptured python
Trying to use make from cygwin using g++ I was getting Access Denied error
I am getting error from inserting array into the database. Error: You have an
I'm getting an Error from Debugger: Error launching remote program: security policy error when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.