C
collinsp
Can any one help me with the code below. I am just learning C and any
help would be appreciated. When I run the program the console opens,
the printf in the function getData prints, I enter the data and when I
hit return the console closes.
Thanks
// Unit 4 Project 44.cpp : Defines the entry point for the console
application.
//
//This program creates customer;s bills for a carpet company
#include "stdafx.h"
#define LABOR .35
#define TAX .085
// Function Declarations
void getData (int* l, int* w, float* disc, float* cost);
int _tmain(int argc, _TCHAR* argv[])
{
//Local Declarations
int l;
int w;
float disc;
float cost;
//Statements
getData (&l, &w, &disc, &cost);
printf("**main: l = %d; w = %d; disc = %f; cost = %f\n", l, w, disc,
cost);
return 0;
} //main
/* ========================getData============================
This function reads two integers and two floats from th ekeyboard.
Pre All parameters are addresses
Post Data read into parameter addressess
*/
void getData (int* l, int* w, float* disc, float* cost)
{
printf("Please enter the length, width, discount and cost: ", l, w,
disc, cost);
scanf ("%d %d %f %f", l, w, disc, cost);
printf("**getData: l = %d; w = %d; disc = %f; cost = %f\n", l, w,
disc, cost);
return;
} //getData
help would be appreciated. When I run the program the console opens,
the printf in the function getData prints, I enter the data and when I
hit return the console closes.
Thanks
// Unit 4 Project 44.cpp : Defines the entry point for the console
application.
//
//This program creates customer;s bills for a carpet company
#include "stdafx.h"
#define LABOR .35
#define TAX .085
// Function Declarations
void getData (int* l, int* w, float* disc, float* cost);
int _tmain(int argc, _TCHAR* argv[])
{
//Local Declarations
int l;
int w;
float disc;
float cost;
//Statements
getData (&l, &w, &disc, &cost);
printf("**main: l = %d; w = %d; disc = %f; cost = %f\n", l, w, disc,
cost);
return 0;
} //main
/* ========================getData============================
This function reads two integers and two floats from th ekeyboard.
Pre All parameters are addresses
Post Data read into parameter addressess
*/
void getData (int* l, int* w, float* disc, float* cost)
{
printf("Please enter the length, width, discount and cost: ", l, w,
disc, cost);
scanf ("%d %d %f %f", l, w, disc, cost);
printf("**getData: l = %d; w = %d; disc = %f; cost = %f\n", l, w,
disc, cost);
return;
} //getData