Thread: Question about strcmp

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    12

    Question about strcmp

    I have a question about the strcmp command and have not been able to locate an answer on any of the on-line reference areas. (including this board)

    Everything that I've read tells me that I should be able to compare strings in nested structures, but so far, I have not been successful.

    I am trying to compare an input string to a string that is included in a structure.

    the structure is:

    typedef struct Resources {

    struct BOOK; /*reference Book structure*/
    struct AUDIO; /*reference Audio structure*/
    struct VIDEO; /*reference Video structure*/
    struct PATRON; /*reference Patron structure*/
    struct BORROWED; /*reference Borrowed structure*/
    struct HOLD; /*reference Hold structure*/

    } RESOURCES;

    Specifically, the compiler comes back with parse errors before RESOURCES on line 28 but not on the other lines using the same code (I don't know if correcting line 28 will cause additional errors.)typedef struct Resources


    if (strcmp(RESOURCES->BOOK->Number, num)==0)


    The rest of my code is also attached.

    Thank you in advance for any assistance.

    readerwhiz

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    There's no reason you can't compare strings no matter how nested they are, but looking at you code 'num' isn't a string so can't be used with strcmp().
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. problem with strings
    By agentsmith in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 12:07 PM
  3. strcmp
    By kryonik in forum C Programming
    Replies: 9
    Last Post: 10-11-2005, 11:04 AM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM