Thread: comparing problem

  1. #1

    Question comparing problem

    i have an array of a structure called video which has a field catagory, im serching the array and comparing the user enterd catagory to the one in the data structure, but even if they are the same it does not recognise it, the comparing code is:

    if(video[i].catagory == usercat)

    i have even printed out the values at this point and they look identical, but it fails to work, any ideas??

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    How are the category member and usercat variable declared, not strings I hope, if they are you cannot use the "==" operator, use strcmp().
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    char arrays (dothese count as strings??)

  4. #4
    Registered User
    Join Date
    Aug 2001
    char arrays are strings, yes therefore...

    if(video[i].catagory == usercat)

    should be...

    if(!strcmp(video[i].catagory, usercat) )
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  3. array problem?
    By ssjnamek in forum C Programming
    Replies: 14
    Last Post: 02-08-2006, 06:03 PM
  4. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM