A basic math programming question

Hi,

I'm trying to learn some basic ideas about programming mathematical functions in C.

I would like the user to be able to input a number with decimals, for instance "2.123"

and then use this input to carry out an equation.

Here is how I've been doing it:

int main (int argc, char * const argv[]) {

/* Variables */

float Xreal;

float Yreal;

float Zreal;

float Xforce;

float Yforce;

float Zforce;

float Tval;

char inXreal[8];

char inYreal[8];

char inZreal[8];

char inZforce[8];

/* Prompts */

/* Get coordinates of real-perspective point */

printf("Xreal value: \n");

gets(inXreal);

Xreal=atoi(inXreal);

printf("Yreal value: \n");

gets(inYreal);

Yreal=atoi(inYreal);

printf("Zreal value: \n");

gets(inZreal);

Zreal=atoi(inZreal);

/* Get Z coordinate of forced-perspective point */

printf("Zforce value: \n");

gets(inZforce);

Zforce=atoi(inZforce);

/* Computation */

Tval=Zforce/Zreal;

Xforce=Tval*Xreal;

Yforce=Tval*Yreal;

/* Output Display */

printf("The point: (%.3f, %.3f, %.3f) was generated with a Tvalue of: %.3f.\n",Xforce,Yforce,Zforce,Tval);

}

This works so long as the input values are whole numbers.

But I would also like to be able to perform these functions using decimals.

I understand that the problem must have something to do with using CHAR and ATOI, but I'm not certain of another way to get user input for decimals, etc.

Can anyone offer some advice?

Thanks!