Thread: Conflicting functions - Help.

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    29

    Question Conflicting functions - Help.

    hello all,
    I need help with this code,
    the compiler says it has conflicting types of functions (scan_b for example)...
    thanks again,
    Livnat.

    Code:
    #include <stdio.h>
    #include <math.h>
    
    void scan_b(double  , int , int );
    void print_b(double  , int  , int );
    void norm_b(double , int , int );
    double std_b(double , int , int );
    double avg_b(double , int , int );
    
    
    
    int main()
    {
    int k,l;
    double c[100][100];
    printf("please enter the number of rows and columns");
    scanf("%d%d" , &k, &l);
    scan_b(c[100][100] ,k,l);
    print_b(c[100][100] ,k,l);
    norm_b( c[100][100] ,  k,  l);
    printf ("the Standard deviation is: %lf" ,std_b( c[100][100] , k,  l));
    printf ("the mean value is: %lf" ,avg_b( c[100][100] ,  k,  l));
    return 0;
    }
    
    
    
    void scan_b(double b[100][100] , int i, int j)
    {
    int m,n;
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   scanf("%d" , &(b[m][n]));
    }
    
    double avg_b(double b[100][100] , int i, int j)
    {
    int m,n;
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   printf("%d" , &(b[m][n]));
    }
    
    void norm_b(double b[100][100] , int i, int j)
    {
    double sum=0,avg, avg2;
    int m,n;
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n];
    
    avg=sum/(i*j);
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   b[m][n]=b[m][n]-avg;
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n]*b[m][n];
    avg2=sum/(i*j);
    
    for (m=0 ; m<i ; m++)
    double std_b(double b[100][100] , int i, int j);        for (n=0 ; n<j ; n++)
                   b[m][n]=(b[m][n])/sqrt(avg2);
    }
    
    int avg_b(double b[100][100] , int i, int j)
    {
    double sum=0,avg, avg2;
    int m,n;
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n];
    
    avg=sum/(i*j);
    return avg;
    }
    
    double std_b(double b[100][100] , int i, int j);
    {
    double avg,avg2,sum,std;
    int m,n;
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n]*b[m][n];
    
    avg2=sum/(i*j);
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n];
    avg=sum/(i*j);
    
    std=sqrt(avg2-pow(avg,2));
    return std;
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    double and double [100][100] are not the same type. Your declaration and definition of scan_b (for example) don't agree. (And you certainly don't want to pass b [100][100] as an argument no matter what.)

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Double post with a different name in the same section.
    What makes you think that's a good idea?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    I'm guessing a sense of overwhelming entitlement coupled with outright desperation.

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    29
    Thank you
    I still have a conflict in the function avg_b
    rags_to_riches is totally right

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Your function definitions and prototypes do not match.
    I believe I already outlined that to you in your other thread.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    1. Your prototypes MUST match your definition (they don't).

    2. scan_b(c[100][100] ,k,l);
    To call the function, it's just
    scan_b(c ,k,l);
    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.

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> I'm guessing a sense of overwhelming entitlement coupled with outright desperation.

    classic.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #9
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Quote Originally Posted by Elysia View Post
    Double post with a different name in the same section.
    What makes you think that's a good idea?
    Quote Originally Posted by rags_to_riches View Post
    I'm guessing a sense of overwhelming entitlement coupled with outright desperation.
    That or he simply tried to change the name after hitting submit; the double post phenomena.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM