Why a i getting this message after i compile my program
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libmingw32.a(main.o):main.c|| undefined reference to `WinMain@16'|

/*
 * p2.cpp
 *
 *  Created on: Oct 7, 2010
 *      Author: saturner
 */
#include "p2.h"
#include <iomanip>
#include <string>

using namespace std;
int main ();

/*
 * Converts an amount measured in cups to milliliters.
 * 1 cup = 236.518538 milliliter
 *
 * cups - amount measured in cups
 *
 * returns amount in milliliters
 */
double convertCupstoMilliliter(double cups)
{
	//modify -1 below to be your new calculated value.

    return cups * 236.518538;

}

/*
 * Returns the percent change from the original to the desired servings.
 * The percent is expressed as a decimal. i.e.:
 *    1   = 100%
 *    0.5 =  50%
 *    1.5 = 150%
 * If either of the serving values is 0, a value of 1 serving is assumed.
 *
 * To calculate the number of servings, the following formula is used:
 *
 * Desired Servings =
 *   | Desired Servings / Original Servings | - 0.1 *
 *   (1 - | Desired Servings / Original Servings | )
 *
 * where | x | is the absolute value of x
 *
 * original - number of servings the recipe was designed for
 * desired - the number of servings wanted
 *
 * returns the % change that should apply to all of the ingredients.
 */
double changeServings(int original, int desired)
{
	//stops any division by 0
	if (original == 0)
	{
		original = 1;
	}
	if (desired == 0)
	{
		desired = 1;
	}
    //end check


    double rate = desired / (double)original;
    if(rate < 0)
        rate = -rate;

    //modify -1 below to be your new calculated value.
	return (rate - 0.1 * (1 - rate));
}



//given an amt and a percent change, find the new amt
/*
 * Given the amount of a ingredient and the % change due to the
 * change in the number of servings, calculates the new amount.
 *
 * amt - original amount from the recipe
 * changeInServings - % to change amt
 *
 * returns corrected amount
 */
double convertAmtByServings(double amt, double changeInServings)
{

    //modify -1 below to be your new calculated value.
    return amt * (changeInServings);
}


//out the ingredient, and amounts
//35, 12.2c, 12.2ml
/* Outputs a single ingredient and its amounts in both cup and milliliter units.
 *
 * Data should be formatted to the following constraints:
 *
 * Value 		Width	Decimal places		Alignment
 * --------------------------------------------------
 * ingredient	35		-					left
 * amtInCups	12		2					right
 * amtInML		12		2					right
 *
 * Floating-point numbers are displayed with a fixed decimal place.
 *
 * Amounts have their units placed after them
 * 	c for cups
 *  ml for milliliters
 *
 * output - output stream to send data to
 * ingredient - ingredient name
 * amtInCups - amount in cup units
 * amtInML - amount in milliliter units
 *
 */
void formatIngredientOutput(ostream &output, string ingredient, double amtInCups, double amtInML)
{
    output << setw(35) << left << ingredient;
    output.precision(2);
    output << setw(12) << fixed << right << amtInCups << "c";
    output << setw(12) << fixed << right << amtInML << "ml";
    output << endl;

}


/*
 * Processes a single line from the recipe.  Reads values from the input stream,
 * converts the values into the correct serving size and units, and writes the values
 * to the output stream.
 *
 * The function also returns the amount of the ingredient in the desired serving size (cups).
 * (This will be useful for calculating the total amount.)
 *
 * Ingredients are assumed to be an a single line (and may have spaces).
 * Amounts are also on a single line.  After reading in the amount, everything else on the line
 * should be ignored.
 *
 * inputStream - input data
 * outputStream - output
 * changeAmt - % of change between the original and desired serving sizes
 *
 * returns amount of ingredient in desired serving size (cups)
 */
double processIngredient(istream &inputStream, ostream &outputStream, double changeAmt)
{
    // read name
    string ingredients;
    getline (inputStream, ingredients);

    // read amount
    double val;
    inputStream >> val;
    inputStream.ignore (100, '\n');
    val = convertAmtByServings (val, changeAmt);

    //output the result
    formatIngredientOutput(outputStream, ingredients, val, convertCupstoMilliliter(val));
        return val;
}

//5 ingredients
//track total amounts
/*
 * Converts a recipe in terms of serving size and units.  Also prints the
 * total amount of ingredients in the course.
 *
 * The original and desired amount of servings should be read in first
 * (in that order).  Everything on the line after the desired amount should
 * be ignored.
 *
 * The five lines of ingredients should be processed and a total printed.
 * The total should follow the same format as that of the ingredients. (See
 * formatIngredientOutput)
 *
 * inputStream - input data
 * outputStream - output
 */
void convertRecipe(istream &inputStream, ostream &outputStream)
{
    // input

        int org, desired;
        inputStream >> org >> desired;
        inputStream.ignore (1000, '\n');
        double changeAmt = changeServings(org, desired);
    // process
        // call procesIngredient 5 times
        double total = 0;

        for (int i = 0; i < 5 ; i++)
        {
            total += processIngredient(inputStream, outputStream, changeAmt);

        }
    // output
        formatIngredientOutput(outputStream, "Total:", total, convertCupstoMilliliter(total));
}

You never define the body of the main function

Each program needs to have a main function. You do have one, but this happened to me before. Not sure how I dealt with it :/ Try capitalizing the 'm' on main so it becomes 'Main'. Apart from that, have a look on google. It's quite a common problem.

BTW:
please don't put a title saying 'help'. If you put the error code, or the end bit, we will be more likely to help. Lucky I have the bother to look at these posts ;)

The OP has not implemented a main function, not sure why you think he does.

int main(); // no function body

>> not sure why you think he does.

He probably got the code from somewhere on the internet (or a classmate) and tried to implement it into his own program to get a homeworkfreebie.

* Created on: Oct 7, 2010
 * Author: saturner

thanks for all tour help i did not have all my files in a code blocks projects i was running them by themselves and @ nick i did not get this from anyone else thank you

If you want to test-compile code without using them in main, you could use and empty main body: int main () {} . But it is required for a program to run to have a main() with a body.

>> @ nick i did not get this from anyone else thank you

No problem. I've become somewhat pessimistic over the years :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.