Mail Archives: djgpp/1998/10/12/06:46:32
From: | Martin Ambuhl <mambuhl AT earthlink DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: function basics
|
Date: | Mon, 12 Oct 1998 06:19:49 -0400
|
Organization: | Nocturnal Aviation
|
Lines: | 55
|
Message-ID: | <3621D7C5.689D9A20@earthlink.net>
|
References: | <3621C580 DOT C4C241F7 AT nceye DOT net>
|
NNTP-Posting-Host: | 1cust185.tnt12.nyc3.da.uu.net
|
Mime-Version: | 1.0
|
X-Posted-Path-Was: | not-for-mail
|
X-ELN-Date: | Mon Oct 12 03:18:23 1998
|
X-Mailer: | Mozilla 4.06 [en] (Win95; U)
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Alexei Akimov wrote:
>
> Hya,
> does anyone know why the code below displays always the same: 317072
> 317068. And to get it read and print data properly?
> thanx
Note that your question in no way concerns djgpp as opposed to other C
implementations. This sort of generic C question at the basic level is
better taken to alt.comp.lang.learn.c-c++.
Reread the section of your text on the proper form of arguments.
Consider the differences between the following and your original code:
#include <stdio.h>
void prompt(int *hrs, int *mnts)
{
printf("Please enter beginning time, "
"hours & minutes separated by whitespace\n"
"> ");
scanf("%d %d", hrs, mnts);
}
int main()
{
int hrs1, mnts1;
prompt(&hrs1, &mnts1);
printf("You entered %d and %d\n", hrs1, mnts1);
return 0;
}
>
> #include <conio.h>
> void prompt( int &hrs, int &mnts)
> {
>
> printf("Plz enter begining time, separating hours & minutes");
> scanf ("%d %d", &hrs, &mnts);
>
> }
> int main()
> {
> int hrs1, mnts1;
>
> prompt( hrs1, mnts1);
> printf ("U entered %d and %d", &hrs1, &mnts1);
> return 0;
> }
--
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive
- Raw text -