type conversion

This is a discussion on type conversion within the C Programming forums, part of the General Programming Boards category; Hi! I have problem with type conversion. when I compile the program I get this error: ( 'count' : redefinition; ...

  1. #1
    Registered User
    Join Date
    Oct 2005

    type conversion

    I have problem with type conversion.
    when I compile the program I get this error:
    ( 'count' : redefinition; different basic types ).
    please tell me about type conversion.

    int count(double houre, double charge);
    int main(){
         double h=4;
        double c=2;
        printf("%\n", count(h,c));
        return 0;
    int count(double houre, double charge){
        double value;
    	    return charge;
    	       return value;
      return 0;	

  2. #2
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Still in the egg

    I get no error while compiling the source! But, i add a "d" into your printf() statement. Program works!

    printf("%d\n", count(h,c));

    I am using : Slackware linux 10.0 , gcc version 3.3.4

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    I just get
    $ gcc -W -Wall foo.c
    foo.c: In function ‘main’:
    foo.c:7: warning: unknown conversion type character 0xa in format
    foo.c:7: warning: too many arguments for format
    But that's just the broken printf() call - nothing to do with count
    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
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    I think the only thing wrong with that, as everyone is saying, is this line:
        printf("%\n", count(h,c));
    it should be
        printf("%d", count(h,c));
        printf("%i", count(h,c));

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you check what is wrong with this code
    By Ron in forum C++ Programming
    Replies: 4
    Last Post: 08-01-2008, 11:59 PM
  2. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 05:33 PM
  3. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 11:52 PM
  4. Windows using Dev-C++
    By Renegade in forum C++ Programming
    Replies: 15
    Last Post: 07-07-2005, 09:29 PM
  5. overloaded operator for type conversion error
    By mangoMan in forum C++ Programming
    Replies: 1
    Last Post: 03-10-2004, 08:38 PM

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