delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/15/16:49:02

From: Michael Goffioul <goffioul AT emic DOT ucl DOT ac DOT be>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Why doesn't this work (correct, running code)
Date: Tue, 15 Jul 1997 14:37:58 +0200
Organization: EMIC - UCL
Lines: 60
Message-ID: <33CB6F26.3C37@emic.ucl.ac.be>
References: <5qf224$6m0$1 AT missing DOT link DOT ca>
NNTP-Posting-Host: ns2.emic.ucl.ac.be
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

James Edwin Cooper wrote:
> 
> Sorry, me again! Anyway, I just made this program, changed it until there
> weren't any DAMN errors, and now it doesn't work! It is a SUPER fast SIN
> calculator (integer values only). The problem is, no matter WHAT number
> you type in, it always pumps out 0.000000. Any reason?
> 
> *** WARNING: DJGPP V1 CODE START ***
	       ^^^^^^^^
You should use Djgpp v2.01 instead ! You can get it from any simtelnet
mirror.

> #include "stdio.h"
> #include "math.h"
> 
> main()
> {
>  float answer,sintable[360];
>  int i,value;
>  char number[3];
>  printf("Welcome to the SUPER HackEd Sin Number Calculator!\n");
>  printf("We are computing your Sin Tables now!\n\n");
>  printf("Progress: ");
>  for(i=0;i<360;i++)
>  {
>   sintable[i]=sin(i);
>   printf(".");
>  }
>  printf(" done!");
>  printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
>  printf("Please enter an integer number to be calculated : ");
>  gets(number);
>  value=atoi(number);
>  answer=sintable[value];
>  printf("\nThe answer is %f.\n\n");
			   ^^
You forgot to tell "printf" where to find the float to be printed.
This should be

   printf("\nThe answer is %f.\n\n",answer); 

> }
> *** WARNING: DJGPP V1 CODE END ***
> 
> Sorry if this doesn't look perfect or run fast, it was a 15 minute hack
> by a newbie. Anyway, If this should work, then can you give me hints?
> Otherwise, a simple fix would be nice! Thanks in advance :)
> -hacked AT iname DOT com

-- 
Michael Goffioul

EMIC - UCL
Batiment Maxwell
Place du Levant, 3
B-1348 Louvain-la-Neuve
Belgium

Tel.: +32 10 47 23 15
Fax.: +32 10 47 87 05

- Raw text -


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