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

  • SEARCH
  • Home
  • 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 8315711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:11:39+00:00 2026-06-08T21:11:39+00:00

I would like to know if design of my program is correct, as well

  • 0

I would like to know if design of my program is correct, as well as to understand if my commented area is doing what it supposed to be doing. I get these compile errors that are associated probably with commented segments of my code, and I would lie to receive some help. THANKS!

  part1.c:15:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'insert'
  part1.c: In function 'main':
  part1.c:43:14: error: incompatible types when assigning to type 'struct point' from               type 'int'
  part1.c:49:44: error: invalid type argument of '->' (have 'struct point')
  part1.c:49:59: error: invalid type argument of '->' (have 'struct point')
  part1.c:55:5: error: incompatible type for argument 1 of 'free'
 /usr/include/stdlib.h:488:13: note: expected 'void *' but argument is of type 'struct point'






char *chars[3]= {"a","b","c"};

int nums[3]= {5,8,9};

struct point {char *letter;
                int number;
           struct point *next;};

struct point* insert(struct point list[],char *rqdLetters, int rqdNums) 
{  
     struct point *new;

     new = (struct point*)malloc(sizeof(struct point));
     if(new == NULL)
     fprintf(stderr,"error!");

     new->letter = rqdLetters;
     new->number = rqdNums; 

     new->next = head;
     head = new; 

     //not sure if i'm returning the a pointer to the start of new list
     return head;
}

int main(int argc, char **argv)                                             
{
   //not sure if i need to declare these here or in the insert 
    struct point list[3];          
    struct point *head = NULL;
    struct point *next; 
    struct point *new;

    int i;
    for (i = 0; i < 3; i++) 
    {
       //return result put back into the pointer to the start of the list
       head[i] = insert(list[i], chars[i], nums[i]);
    }

    int j;
    for(j = 0; j < 3; j++)
    {
       printf("letter %s and number %d\n", list[j]->letter, list[j]->number);
    }

    int z;
    for(z = 0; z < 3; z++)
    {
       free(list[z]);
    }

    return 0;
  }
  • 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-08T21:11:40+00:00Added an answer on June 8, 2026 at 9:11 pm

    At a glance, there are several issues with your code. Firstly, you’re not declaring your variables correctly.

    new = list;
    

    should be:

    struct point* new;
    

    Your function signature also looks a little suspect. If you’re returning a pointer to your data structure, it should be something like:

    struct point* insert(...) { ... }
    

    At a more general level, I does seem like your idea of a linked list may be a little off. To represent a list, you should only need to hold on to the head and tail of the list, instead of keep an array of your points.

    It usually helps if you create a data structure to hold these pointers. You can then pass this structure around to functions that operate on the list e.g. the insert() function.

    As a quick example (untested):

    struct node {
      struct node *next;
      char letter;
      int number;
    }
    
    struct list {
      struct node *head;
      struct node *tail;
    }
    
    /* create a new list */
    struct list* list_new(void) {
      struct list *L = malloc(sizeof(struct list));
      L->head = NULL;
      L->tail = NULL;
    }
    
    /* add a new node to the list */
    void list_insert(struct list *list, char in_letter, int in_number) {
      struct node *node = malloc(sizeof(struct node));
      node->letter = in_letter;
      node->number = in_number;
      node->next = NULL;
    
      if (list->head == NULL) {  /* empty list */
        list->head = node;
        list->tail = node;
      } else { /* append to list */
        list->tail->next = node;
        list->tail = node;
      }
    }
    

    You can then use it as such:

    int i;
    char chars[3]= {"a","b","c"};
    int nums[3]= {5,8,9};
    
    struct list *mylist = list_new();
    
    for (i = 0; i < 3; i++) 
    {
       list_insert(mylist, chars[i], nums[i]);
    }
    

    In response to:

    … and i am not sure if i am supposed to declare it inside insert or main, i did in the main however

    This depends on where you intend to use the variables and the intended lifespan of these variables. As stated in the comments above, you might want to polish up on your understanding of scoping rules.

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

Sidebar

Related Questions

Im new to database design and I would like to know what is the
I'm doing a small research of mobile platforms and I would like to know
i would like know some reference. I know i can googling it. but prefer
Would like to know what a programmer should know to become a good at
Would like to know the c# code to actually retrieve the IP type: Static
Would like to know how to integarate cruise control with maven? Cruise Control comes
Would like to know how to hide an div after a set of css3
I would like to know what code to use to convert a double[] array
I would like to know, how can we change the SRC url for IFRAME
I would like to know if there exists any kind of library or workaround

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.