Need help inputting Float #'s
Michael Hart
hart at blackjack.dt.navy.mil
Tue Jul 17 23:26:46 AEST 1990
Yes, this is probably a stupid, obvious (RTFM)
question to all you C geniuses, but, I have
RTFM and the FM is not very explicit. What
a surprise.
I am trying to input a floating point number into
my prog, in the format nnnnnn.mm . Using the following
code, I see that it is reading the correct number
of chars, but apparantly either is not storing them
the way I want, or just not printing them out.
Please respond via E-mail; that way I won't get too
many flames for this question.
BTW,
#define SYSTEM SGI4D/25
#define OS 3.2.1
thanx
code follows:
=======================================
#include <stdio.h>
float *number;
char *buffer[80];
int *c1;
main()
{
printf("Please enter a number with a decimal point : ");
gets(buffer);
printf("\n");
sscanf(buffer,"%f%n",&number,&c1);
printf("(debug: num of chars read was : %d)\n",c1);
printf("\n");
printf("\n\n\nThe data as entered:\n");
printf("decimal number : %#6.2f\n",number);
printf("\n");
}
========================================
--
-------------------------------------------------------------------------------
Michael G. Hart hart at blackjack.dt.navy.mil / mhart at dtrc.dt.navy.mil
DTRC/DoD | "Wherever you go, there you are."- me
DISCLAIMER: If you want the Navy's opinion, talk to Secretary Cheney.
--
-------------------------------------------------------------------------------
Michael G. Hart hart at blackjack.dt.navy.mil / mhart at dtrc.dt.navy.mil
DTRC/DoD | "Wherever you go, there you are."- me
DISCLAIMER: If you want the Navy's opinion, talk to Secretary Cheney.
More information about the Comp.lang.c
mailing list