For Programmers: Free Programming Magazines  


Home > Archive > C > March 2004 > Beginner here....









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Beginner here....
Link Skywalker 14

2004-03-28, 10:00 pm

I copied this directly from the book "C: step by step" published in
1989, it refuses to compile. Anybody see what's wrong with it? Much
appreciated.

#include <stdio.h>
main()
{
float weight, value;
char beep;
beep = '\007';
printf("Are you worth your weight in gold?\n");
printf("Please enter your weight in punds, ");
printf ("and we'll see.\n");
scanf("%f", $weight);
value = 400.0 * weight * 14.5833;
printf("%cYour weight in gold is worth $%.2f%c.\n",beep,value,beep);
printf("You are easily worth that! If gold prices drop, ");
printf("Eat more\nto maintain your value.\n");

}


This is the error message I get:

c:\program files\miracle c\weight_in_gold.c: line 10: Parse Error,
expecting `')'' or `',''
'scanf("%f", $weight)'
aborting compile
Arthur J. O'Dwyer

2004-03-28, 10:00 pm


On Sun, 27 Mar 2004, Link Skywalker 14 wrote:
>
> I copied this directly from the book "C: step by step" published in
> 1989, it refuses to compile. Anybody see what's wrong with it? Much
> appreciated.
>
> #include <stdio.h>
> main()


int main(void)

> {
> float weight, value;
> char beep;
> beep = '\007';
> printf("Are you worth your weight in gold?\n");
> printf("Please enter your weight in punds, ");


Copied it directly, huh?

> printf ("and we'll see.\n");
> scanf("%f", $weight);


Nope -- $ is not &. Try a more direct copy next time.

> value = 400.0 * weight * 14.5833;
> printf("%cYour weight in gold is worth $%.2f%c.\n",beep,value,beep);
> printf("You are easily worth that! If gold prices drop, ");
> printf("Eat more\nto maintain your value.\n");


return 0;

> }


-Arthur

Emmanuel Delahaye

2004-03-28, 10:00 pm

In 'comp.lang.c', linkskywalker14@yahoo.com (Link Skywalker 14) wrote:

> scanf("%f", $weight);


Too much Pascal!

scanf("%f", &weight);

> This is the error message I get:
>
> c:\program files\miracle c\weight_in_gold.c: line 10: Parse Error,
> expecting `')'' or `',''
> 'scanf("%f", $weight)'
> aborting compile


--
-ed- emdelYOURBRA@noos.fr [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=cpp
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Martin Ambuhl

2004-03-28, 10:00 pm

Link Skywalker 14 wrote:

> I copied this directly from the book "C: step by step" published in
> 1989, it refuses to compile. Anybody see what's wrong with it? Much
> appreciated.


2c2
< main()
---
> int main(void)

10c10
< scanf("%f", $weight);
---
> scanf("%f", &weight);

16c16
<
---
> return 0;





> #include <stdio.h>
> main()
> {
> float weight, value;
> char beep;
> beep = '\007';
> printf("Are you worth your weight in gold?\n");
> printf("Please enter your weight in punds, ");
> printf ("and we'll see.\n");
> scanf("%f", $weight);
> value = 400.0 * weight * 14.5833;
> printf("%cYour weight in gold is worth $%.2f%c.\n",beep,value,beep);
> printf("You are easily worth that! If gold prices drop, ");
> printf("Eat more\nto maintain your value.\n");
>
> }
>
>
> This is the error message I get:
>
> c:\program files\miracle c\weight_in_gold.c: line 10: Parse Error,
> expecting `')'' or `',''
> 'scanf("%f", $weight)'

^^
notice!

> aborting compile

Materialised

2004-03-28, 10:00 pm

Link Skywalker 14 wrote:
> I copied this directly from the book "C: step by step" published in
> 1989, it refuses to compile. Anybody see what's wrong with it? Much
> appreciated.
>
> #include <stdio.h>
> main()
> {
> float weight, value;
> char beep;
> beep = '\007';
> printf("Are you worth your weight in gold?\n");
> printf("Please enter your weight in punds, ");
> printf ("and we'll see.\n");
> scanf("%f", $weight);

<snip>
scanf("%f", &weight);

-=-=-
.... This tagline is identical to the one you are reading.
Unauthorized use of this post, materials, characters, images, sounds,
odors, severed limbs, noodles, wierd dreams, strange looking fruit,
oxygen, and certain parts of Jupiter are strictly forbidden. If I find
you violating, or molesting my property in any way, I will employ a pair
of burly convicts to find you, kidnap you, and perform god-awful sexual
experiments on you until you lose the ability to sound out vowels. I
don't know why you are still reading this, but by doing so you have
proven that you have far too much time on your hands, and you should go
plant a tree, or read a book or something
Christopher Benson-Manica

2004-03-29, 11:30 am

Link Skywalker 14 <linkskywalker14@yahoo.com> spoke thus:

> char beep;
> beep = '\007';
> printf("%cYour weight in gold is worth $%.2f%c.\n",beep,value,beep);


Non-portable; use the standard \a (BEL) escape sequence in the printf
instead to get the "beep".

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com