delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/07/18:46:04

Date: Wed, 8 Mar 2000 05:16:49 +0600 (LKT)
From: Kalum Somaratna aka Grendel <kalum AT crosswinds DOT net>
X-Sender: root AT darkstar DOT grendel DOT net
To: Lonnie Lee <airtime AT kih DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: help with C
In-Reply-To: <8a3ps6$gba$1@news3.icx.net>
Message-ID: <Pine.LNX.4.10.10003080509330.999-100000@darkstar.grendel.net>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 8 Mar 2000, Lonnie Lee wrote:

> Below is a code that does not work:
> 
> /* Program to Calculate the product of two numbers. */
> #include <stdio.h>
> 
> int a,b,c;
> 
> int product(int x, int y) ;

<snip>

> /* Function returns the product of the two values provide */
> int pruduct(int x, int y)
^^^^^^^^^^^^^^^^^^^^ Here is the problem, earlier a function called
product has being defined but here the function name is misspelled as
pruduct (_note_ the letter u instead of the letter o). So just change this
to product (with the letter o) and every thing should be alright.

> {
> return (x * y);
> }
 
> OK you can "compile" no problem but when you go to build it you get an
> error.
> "undefined reference to 'product'"

This is because the linker is searching for a function called "int
product(int x,int y)" (without the quotes) but it can't find it. 

The reason is that you have misspelled product as pruduct and as a result
the linker can find a function called pruduct but _not_ product, therefore
the linker informs you that it can't find a function called product to
link in.

> If anyone could help I would appreciate it. If there is a site or newsgroup
> where I need to go that would be great. Because I am tring to learn it woul

I think the newsgroup comp.lang.c would be of great assistance to you as
this newsgroup is more towards discussion about DJ's port of the GNU C
compiler.

Grendel


Hi, I'm a signature virus. plz set me as your signature and help me spread
:)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019