Thread: strange error when compare element of stracture and word

  1. #1
    Registered User
    Join Date
    Apr 2017
    Posts
    51

    Post strange error when compare element of stracture and word

    I have a structure, one of the element is spider_local.trd_sysmat_intliser_bnk_id_cd, which has 10 chars, copy overthere value "REGV-AAAA", I need only las for chars.
    Code:
       I compare if ( memcmp (spider_local.trd_sysmat_intliser_bnk_id_cd,"REGV",4) == 0)   {       do something   }
    When I compile the program give an error: Character constant 'REGV' has more than 1 character. Function argument assignment between types "const void*" and "int" is not allowed Coul dyou please let me know why? Thanks,

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    You should you type up a quick simplified version of the program that exhibits the problem and post that, so we don't have to guess at what you're doing wrong.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    Somehow you managed to type it correctly here
    if ( memcmp (spider_local.trd_sysmat_intliser_bnk_id_cd,"REGV" ,4) == 0)
    Double quotes good.

    But wrong in your actual code.
    if ( memcmp (spider_local.trd_sysmat_intliser_bnk_id_cd,'REGV' ,4) == 0)
    Single quotes bad.
    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.

  4. #4
    Registered User
    Join Date
    Apr 2017
    Posts
    51
    thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compare input with array element
    By coffee_cup in forum C Programming
    Replies: 14
    Last Post: 12-03-2012, 12:03 PM
  2. Replies: 28
    Last Post: 10-23-2011, 07:17 PM
  3. initializer element is not constant error - help
    By jay32m in forum C Programming
    Replies: 7
    Last Post: 11-17-2010, 03:24 PM
  4. Replies: 60
    Last Post: 05-31-2010, 10:57 AM
  5. how to compare element in array
    By hlam in forum C++ Programming
    Replies: 7
    Last Post: 11-29-2003, 12:05 AM

Tags for this Thread