Thread: comparing struct elemet to string

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    2

    Question comparing struct elemet to string

    sorry cant work o t how to do this know it must sound dumb to you all

    i need to compare a varchar(len 3) element of a struct(6th element starting at pos 43) to a fixed string 'AJP'
    as i need to take one set of actions if it is equal to AJP and a different set if it is not

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    Say
    Code:
    if ( strncmp( &foo.member[43], "AJP", 3 ) == 0 )
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    2
    works perfect,
    thank you so much, i've wasted so muct time trying to do this just going round in circles and being too proud too ask for help and in minutes you sort me out, your an absolute star.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help assignment due tomorrow
    By wildiv in forum C Programming
    Replies: 6
    Last Post: 01-27-2010, 08:38 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 06:52 PM
  5. Replies: 4
    Last Post: 03-03-2006, 02:11 AM