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 4 3011
On Feb 24, 4:57*pm, colli...@sbcglobal.net wrote:
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 parametersare 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- Hide quoted text -
- Show quoted text -
I think you dont want the console to close. You could do that by
putting a getch(); just before the return 0 statement in the main().
Plz post C questions in C forums.
Suresh M. Shenoy
On Feb 24, 2:05*pm, suresh shenoy <msureshshe...@gmail.comwrote:
On Feb 24, 4:57*pm, colli...@sbcglobal.net wrote:
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- Hide quoted text -
- Show quoted text -
I think you dont want the console to close. You could do that by
putting a getch(); just before the return 0 statement in the main().
Plz post C questions in C forums.
Suresh M. Shenoy- Hide quoted text -
- Show quoted text -
On Feb 24, 10:57 pm, colli...@sbcglobal.net wrote:
Can any one help me with the code below. I am just learning C
and any help would be appreciated.
This group discusses C++, not C, and so is unlikely to be of any
help to you in C. However...
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.
That's something outside your program which is doing it. Your
program never opens a console (and never closes one either). So
you really should ask in a group specific to your environment.
// Unit 4 Project 44.cpp : Defines the entry point for the console
application.
If your file name ends in .cpp, you're almost certainly working
in C++, and not C. Your first step is to decide which one you
want, and use it. Your code looks like C; if that's what you
want, rename your file to end in .c (and post your questions in
comp.lang.c).
Also, your comment above is false for both C and C++. The entry
point for all applications (console or otherwise) in both C and
C++ is a function called main, and I don't see any function
called main in your code.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34 co******@sbcglobal.net wrote:
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"
[SNIP]
That tells me you are using Microsoft Visual C++ to run the program.
Hit ctrl-F5 instead of just F5 to run it.
--
Jim Langston ta*******@rocketmail.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kay Schluehr |
last post by:
The documentation of the Python console behaviour is not correct
anymore for Python 2.4.1. At least for the Win2K system I'm working on
'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc.
The Python interpreter tells me instead:
>>> quit
'Use Ctrl-Z plus Return to exit.'
Nah, 'Ctrl-Z' is now undo :-)
|
by: Richard Lionheart |
last post by:
Hi All,
When I create a Console app in VS.net and run it, the Console window opens
briefly and closes. If I was running a .bat command file, I'd append a
pause stmt at the end. What can I do in VS? I'm a newbie and keeping that
window open would be helpful for studying.
Thanks in advance,
Richard
|
by: James |
last post by:
I'm totally new to C++ and when I try to execute the simple program I have
written, it closes the console application as soon as it has finished
excuting. This obviously means I cannot see the contents of the console
window.
I'm developing it using Visual C++ 2003, using the console application
template.
|
by: Jim Heavey |
last post by:
When I run a console application by bringing up a dos window and then running
the exe, I noticed that when I close the dos window, this kills my
application. My question is, Is there some way that I can detect this and
ensure that I can control how my application closes? I need to ensure that
the disk file I have open that I properly close...
|
by: Alvo von Cossel I |
last post by:
hi,
i have a working console app. however, it closes as soon as it opens.
i know that it works because i can just about read it. how do i stop it from
closing straight after opening?
--
Alvo von Cossel I of Germany
| |
by: Klaus Löffelmann |
last post by:
Hi,
it may be a stupid question and maybe I'm not seeing the wood for the trees,
but how do I let the console window remaining open after the app terminates?
(Console.Readline as last code line won't work in my case, since I'm testing
a class' finalize-method).
Thanks
|
by: Giojo |
last post by:
Hello guys!
I can't resolve this problem.. I want my programm in c# working with
only console if there are some parameters, but if someone make
double-click on the exe I want to start the graphic GUI without the
black console on background..
Now I check if there are some parameters and if there aren't parameters
I run the GUI (with the black...
|
by: Marin |
last post by:
Right now my solution to this is adding Console.ReadLine at the end but I'm
wondering if it's possible to do it automatically?
If I chose "Start without debug" it does just that, it pauses right before
the console window closes, but "Start with debug" closes the window right
away.
|
by: TC |
last post by:
I'm trying to debug a console application, but I can't see the console
output. I've seen many references which say that console output is
supposed to appear on the Output window when the application is run in
Debug mode. However, I just can't get that to work.
I'm using Visual Studio 2005. I've confirmed that my application is
compiled as a...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |