Suri

Suri

  • NA
  • 113
  • 13k

Is it possible to return a struct from a function in C? I tried, can y

Jun 29 2021 11:59 AM

Is it possible to return a struct from a function in C? I tried, can you tell me what is wrong.

struct command(){
  
    struct list_commands {
        char selector[LENGHT];
        int index;
        char direction[LENGHT];
        int locations;
    } list_commands;

    printf("Insert the command in the format: <selector> <index> <direction> <locations>");
    scanf("%s %d %s %d", &selector, &index, &direction, &locations);
    
  
    return list_commands;
}

 


Answers (2)