Request for something not in a structure, what does this mean?

This is a discussion on Request for something not in a structure, what does this mean? within the C Programming forums, part of the General Programming Boards category; The parts in green are the problematic parts The error was : request for member 'name' in something not a ...

  1. #1
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463

    Request for something not in a structure, what does this mean?

    The parts in green are the problematic parts

    The error was : request for member 'name' in something not a structure or union

    Code:
    // System include files
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>
    
    // Local include files
    #include "quadtree.h"
    
    // Constants
    #define MAXLENGTH    200
    #define LENGTH 20 //Length of name of country
    
    typedef struct country Country;
    
    struct country {
      char name[LENGTH + 1];
      int dimen;
      int num;
      Country *next;
    };
    
    Country *makeList(char comm[MAXLENGTH]);
    // Main function
    int main( void )
    {
      char command[MAXLENGTH];
      char c;
    
    
      printPrompt();
    
      while( fgets( command, MAXLENGTH, stdin ) != NULL ) {
    
        int  imgNum;
        char *p;
    
        if(( p=strrchr( command, '\n')) != NULL ) {
          *p = '\0'; // remove '\n' at end of line
        }
        // find the first non-space character in the command
        p = command;
        while(isspace(*p)) {
          p++;
        }
        c = *p;
    
        if( isdigit(c)) {
          if( sscanf( command, "&#37;d", &imgNum ) == 1 ) {
    
            // INSERT CODE FOR <k> COMMAND
          }
        }
        else switch( c ) {
    
        case 'h': // help
    
          printf(" A - Add image\n" );
          printf(" I - Index\n" );
          printf(" P - Print image\n" );
          printf(" F - Forward\n" );
          printf(" B - Back\n" );
          printf("<k>- make image number k the current image\n");
          printf(" D - Delete image\n" );
          printf(" L - Look for image\n" );
          printf(" R - Rotate image counterclockwise\n" );
          printf(" M - Mirror image (reflect vertically)\n" );
          printf("NE - zoom into North East corner\n" );
          printf("NW - zoom into North West corner\n" );
          printf("SW - zoom into South West corner\n" );
          printf("SE - zoom into South East corner\n" );
          printf(" O - zoom Out\n" );
          printf(" U - Undo\n" );
          printf(" H - Help\n" );
          printf(" Q - Quit\n" );
          break;
    
          // INSERT CODE FOR OTHER COMMANDS
          
        case 'a':
          makeList(command);
          break;
    
        case 'q': // quit program
          printf("Bye!\n");
          return 0;
          break;
    
        default:
          printf("Unrecognized command: %s\n", command );
          break;
        }
    
        printPrompt();
      }
    
      return 0;
    }
    
     Country *makeList(char comm[MAXLENGTH]){
    
            int num;
    
            Country *list;
            list = (Country*)malloc(sizeof(Country));
            list-> num = num;
            list-> next = NULL;
            comm->name;
            return (list);
    }
    Last edited by JFonseka; 10-22-2007 at 07:35 AM.

  2. #2
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159

    !!!!!

    you can more specify error please !!!

  3. #3
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    The error was : request for member 'name' in something not a structure or union

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    Country *makeList(char comm[MAXLENGTH])
    ...
            comm->name;
    The variable comm is a char array, and you are trying to use "name" like it was a struct. This is what the compiler is "unhappy" about.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem referencing structure elements by pointer
    By trillianjedi in forum C Programming
    Replies: 19
    Last Post: 06-13-2008, 06:46 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. problem with c and xml
    By dianazheng in forum C Programming
    Replies: 11
    Last Post: 05-26-2005, 08:10 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21