Problem with a program...

This is a discussion on Problem with a program... within the C++ Programming forums, part of the General Programming Boards category; I've been working on an program for a class and I keep getting an error when I try to compile ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    2

    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
    Posts
    219
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,554
    > error C2664: 'strcmp' : cannot convert parameter 2 from 'char' to 'const char *'
    You used single quotes instead of double quotes
    Code:
    strcmp( buff, 'a' );
    You forgot an ampersand
    Code:
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    May 2005
    Posts
    2
    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

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