Question about strcmp

This is a discussion on Question about strcmp within the C Programming forums, part of the General Programming Boards category; I have a question about the strcmp command and have not been able to locate an answer on any of ...

  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
    Attached Files Attached Files

  2. #2
    zen
    zen is offline
    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, 01:14 PM
  2. problem with strings
    By agentsmith in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 01:07 PM
  3. strcmp
    By kryonik in forum C Programming
    Replies: 9
    Last Post: 10-11-2005, 12:04 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM

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