Thread: Problem with a program...

  1. #1
    Registered User
    Join Date
    May 2005

    Problem with a program...

    I've been working on an program for a class and I keep getting an error when I try to compile it. I can't find a way to fix it, so I thought I'd ask for help here.

    The program does a binary search to look up a student's name in a list. The user inputs a name, and that name is passed to a function that uses strcmp to perform the search on my list.

    The error:

    error C2664: 'strcmp' : cannot convert parameter 2 from 'char' to 'const char *'
    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

    Parameter 2 is the name inputted by the user. This error occurs on the line where strcmp is used.

    Can anyone tell me what this means?

  2. #2
    Wen Resu
    Join Date
    May 2003
    I need to see the code but imagine that your are passing the array wrong.
    post your function and i'll look

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > error C2664: 'strcmp' : cannot convert parameter 2 from 'char' to 'const char *'
    You used single quotes instead of double quotes
    strcmp( buff, 'a' );
    You forgot an ampersand
    strcmp( buff, mystring[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.

  4. #4
    Registered User
    Join Date
    May 2005
    Ah, the problem was with the array. It seems that I left some brackets off at one point and just hadn't caught my mistake. Thanks for the help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi Thread Program Problem
    By ZNez in forum C Programming
    Replies: 1
    Last Post: 01-03-2009, 10:10 AM
  2. Program Termination Problem
    By dacbo in forum C Programming
    Replies: 3
    Last Post: 01-23-2006, 01:34 AM
  3. Inheritance and Dynamic Memory Program Problem
    By goron350 in forum C++ Programming
    Replies: 1
    Last Post: 07-02-2005, 02:38 PM
  4. Replies: 20
    Last Post: 06-12-2005, 11:53 PM
Website Security Test