public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: atof()
       [not found] <Pine.LNX.4.33L2.0208191404020.11506-100000@sol.galaxy.acm.jhu.edu>
@ 2002-08-19 12:57 ` Reinaldo Nolasco Sanches
  0 siblings, 0 replies; 7+ messages in thread
From: Reinaldo Nolasco Sanches @ 2002-08-19 12:57 UTC (permalink / raw)
  To: gcc

Thanks a lot to all helps...

And very very sorry for my stupid question of std C in gcc mainlist...


:)


Thanks.. :)




=====
"When you know Slackware, you know Linux... when you know Red Hat, all you know is Red hat"

- Anyone seen smoking will be assumed to be on fire and will be summarily put out.
- Power doesn't corrupt people, people corrupt power.

- r_linux@yahoo.com -- http://slackware.linuxbr.org
- UIN: 42853394 - irc.brasnet.org(#slackware)

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: atof()
  2002-08-19 10:49 atof() Reinaldo Nolasco Sanches
                   ` (3 preceding siblings ...)
  2002-08-19 11:13 ` atof() Andreas Jaeger
@ 2002-08-19 11:18 ` Erik Trulsson
  4 siblings, 0 replies; 7+ messages in thread
From: Erik Trulsson @ 2002-08-19 11:18 UTC (permalink / raw)
  To: Reinaldo Nolasco Sanches; +Cc: gcc

On Mon, Aug 19, 2002 at 10:49:53AM -0700, Reinaldo Nolasco Sanches wrote:
> 
> I have a problem with atof()... and I don't understand because it...
> When I use atof() to get a value of a string... and put in my double var, the value is not the
> same...

This is not the right list for this kind of question but I will answer
anyway.  (This list is for discussion of the development of gcc, not
how to use gcc.)

If you use atof() you need to include stdlib.h first to get the
prototype.  Otherwise the compiler will assume atof() returns an int
and thus generate bad code.

> 
> I make a little example...
> 
> #include <stdio.h>
> 
> int main()
> {


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: atof()
  2002-08-19 10:49 atof() Reinaldo Nolasco Sanches
  2002-08-19 11:03 ` atof() H. J. Lu
  2002-08-19 11:09 ` atof() Janis Johnson
@ 2002-08-19 11:13 ` Brad House
  2002-08-19 11:13 ` atof() Andreas Jaeger
  2002-08-19 11:18 ` atof() Erik Trulsson
  4 siblings, 0 replies; 7+ messages in thread
From: Brad House @ 2002-08-19 11:13 UTC (permalink / raw)
  To: Reinaldo Nolasco Sanches, gcc

#include <stdlib.h> needs to be added.  The default
data type for an undeclared function is int which
will cause oddities like that.  Always compile
with -Wall when debugging stuff, as it will
report such errors.

-Brad

Reinaldo Nolasco Sanches wrote:

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: atof()
  2002-08-19 10:49 atof() Reinaldo Nolasco Sanches
                   ` (2 preceding siblings ...)
  2002-08-19 11:13 ` atof() Brad House
@ 2002-08-19 11:13 ` Andreas Jaeger
  2002-08-19 11:18 ` atof() Erik Trulsson
  4 siblings, 0 replies; 7+ messages in thread
From: Andreas Jaeger @ 2002-08-19 11:13 UTC (permalink / raw)
  To: Reinaldo Nolasco Sanches; +Cc: gcc

Reinaldo Nolasco Sanches <r_linux@yahoo.com> writes:

> I have a problem with atof()... and I don't understand because it...

This is the wrong group for such kind of questions.  I guess this
might be even answered in the C FAQ or a good C book.

If you compile your program with warnings enabled, you'll get:
$ gcc -Wall t.c
t.c: In function `main':
t.c:10: warning: implicit declaration of function `atof'

Without a prototype the function is declared as returning int instead
of doubles.

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: atof()
  2002-08-19 10:49 atof() Reinaldo Nolasco Sanches
  2002-08-19 11:03 ` atof() H. J. Lu
@ 2002-08-19 11:09 ` Janis Johnson
  2002-08-19 11:13 ` atof() Brad House
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Janis Johnson @ 2002-08-19 11:09 UTC (permalink / raw)
  To: Reinaldo Nolasco Sanches; +Cc: gcc

On Mon, Aug 19, 2002 at 10:49:53AM -0700, Reinaldo Nolasco Sanches wrote:
> 
> I have a problem with atof()... and I don't understand because it...
> When I use atof() to get a value of a string... and put in my double var, the value is not the
> same...
> 
> I make a little example...
> 
> #include <stdio.h>
> 
> int main()
> {
> 	double teste;
> 	char   strteste[10];
> 	
> 	strcpy( strteste, "120.1" );
> 	
> 	teste = atof( strteste );
> 	
> 	printf( "\n\tResult is = %.2f\n\n", teste );
> 	
> 	return 0;
> }
> 
> and the result is this
> 
>     Result is = 1078984704.00
> 

This mailing list is for questions about developing GCC, not about
using it.

A hint, though: try compiling with -Wall to turn on more warnings.

Janis

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: atof()
  2002-08-19 10:49 atof() Reinaldo Nolasco Sanches
@ 2002-08-19 11:03 ` H. J. Lu
  2002-08-19 11:09 ` atof() Janis Johnson
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: H. J. Lu @ 2002-08-19 11:03 UTC (permalink / raw)
  To: Reinaldo Nolasco Sanches; +Cc: gcc

On Mon, Aug 19, 2002 at 10:49:53AM -0700, Reinaldo Nolasco Sanches wrote:
> 
> I have a problem with atof()... and I don't understand because it...
> When I use atof() to get a value of a string... and put in my double var, the value is not the
> same...
> 
> I make a little example...
> 
> #include <stdio.h>

You need

#include <stdlib.h>

to get the prototype of atof.

> 
> int main()
> {
> 	double teste;
> 	char   strteste[10];
> 	
> 	strcpy( strteste, "120.1" );
> 	
> 	teste = atof( strteste );
> 	
> 	printf( "\n\tResult is = %.2f\n\n", teste );
> 	
> 	return 0;
> }
> 
> and the result is this
> 
>     Result is = 1078984704.00
> 
> and I don't understand this... I make this in several PCs... and in a SuSE, in a Slackware and in
> a RedHat(urgg!), and in all the erro ocurred...
> 
> I don't know if I need set a specific #define... or a specific environment var...
> 
> Please... anybody can help me ???
> 


H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* atof()
@ 2002-08-19 10:49 Reinaldo Nolasco Sanches
  2002-08-19 11:03 ` atof() H. J. Lu
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Reinaldo Nolasco Sanches @ 2002-08-19 10:49 UTC (permalink / raw)
  To: gcc

I have a problem with atof()... and I don't understand because it...
When I use atof() to get a value of a string... and put in my double var, the value is not the
same...

I make a little example...

#include <stdio.h>

int main()
{
	double teste;
	char   strteste[10];
	
	strcpy( strteste, "120.1" );
	
	teste = atof( strteste );
	
	printf( "\n\tResult is = %.2f\n\n", teste );
	
	return 0;
}

and the result is this

    Result is = 1078984704.00

and I don't understand this... I make this in several PCs... and in a SuSE, in a Slackware and in
a RedHat(urgg!), and in all the erro ocurred...

I don't know if I need set a specific #define... or a specific environment var...

Please... anybody can help me ???

I compiled with...
   gcc -i teste.c -o teste


Thanks a lot in advance...




=====
"When you know Slackware, you know Linux... when you know Red Hat, all you know is Red hat"

- Anyone seen smoking will be assumed to be on fire and will be summarily put out.
- Power doesn't corrupt people, people corrupt power.

- r_linux@yahoo.com -- http://slackware.linuxbr.org
- UIN: 42853394 - irc.brasnet.org(#slackware)

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-08-19 12:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.33L2.0208191404020.11506-100000@sol.galaxy.acm.jhu.edu>
2002-08-19 12:57 ` atof() Reinaldo Nolasco Sanches
2002-08-19 10:49 atof() Reinaldo Nolasco Sanches
2002-08-19 11:03 ` atof() H. J. Lu
2002-08-19 11:09 ` atof() Janis Johnson
2002-08-19 11:13 ` atof() Brad House
2002-08-19 11:13 ` atof() Andreas Jaeger
2002-08-19 11:18 ` atof() Erik Trulsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).