Thread: Need help, I'm a begginer!

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    2

    Question Need help, I'm a begginer!

    Hello all,

    As you may see, I am new to this forum.
    I started programming a little while ago, I'm not that good yet, still can't understand pointers, or insert pictures, but I do exercise by making loads of programs.

    I am trying to make a program that will find me all the dividers of a certain number.
    I get an error message saying "Error: too few arguments to function "etape1""
    Can anyone please find my error?

    Here is my source code:


    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>

    // Trouve TOUT les diviseurs d'un nombre.

    int etape1(int divise, int nombreEntre, int resultat)
    {
    do
    {
    if (nombreEntre%divise == 0);
    {
    printf("%d\n", divise);
    }
    divise++;
    } while (divise < nombreEntre);
    return 0;
    }


    int main(int argc, char *argv[])
    {

    int nombreEntre = 0, resultat = 0;
    printf("Entrez un nombre pour voir tout ses diviseurs\n ");
    scanf("%d", &nombreEntre);
    resultat = etape1(nombreEntre); Edit: This is where the error is.
    return 0;
    }


    Thanks a lot, Jonathan Poll

  2. #2
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    When you call etape1 near the end of your program, you are only giving it nombreEntre. It expects three arguments, namely divise, nombreEntre, and resultat.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Look at the definition of the function ...
    Code:
    int etape1(int divise, int nombreEntre, int resultat)
    and the way you are calling it...
    Code:
    resultat = etape1(nombreEntre);
    Now... do you see anything wrong with that picture?
    (hint: Listen to your compiler's error message)

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    2
    Quote Originally Posted by CommonTater View Post
    Look at the definition of the function ...
    Code:
    int etape1(int divise, int nombreEntre, int resultat)
    and the way you are calling it...
    Code:
    resultat = etape1(nombreEntre);
    Now... do you see anything wrong with that picture?
    (hint: Listen to your compiler's error message)
    Thanks both of you for the quick replies!

    Yes, I do see the error, also helps that the previous replier answered

    Thanks a lot both of you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Begginer Problem: Extracting words from sentence
    By barlas in forum C++ Programming
    Replies: 5
    Last Post: 05-04-2006, 03:17 PM
  2. 2 Begginer questions...
    By SoulBlade in forum C++ Programming
    Replies: 5
    Last Post: 01-18-2006, 05:04 PM
  3. Good C++ books for a begginer
    By Rare177 in forum C++ Programming
    Replies: 13
    Last Post: 06-22-2004, 04:30 PM
  4. begginer: having trouble with "if" command.
    By imortal in forum C Programming
    Replies: 2
    Last Post: 01-08-2003, 08:34 PM
  5. Making text adventures (begginer)
    By funkydude9 in forum C++ Programming
    Replies: 6
    Last Post: 03-08-2002, 03:28 AM