Hi,
So I've changed the code so that there are a set number of loops, in this case 8 (determined by variable "wloop").
This means I can establish a set number of variables to each hold the value for the output of one time through the loop.
I need 8 variables:
char force-vertex_0
char force-vertex_1
char force-vertex_2
...etc
char force-vertex_7
and at the end of each loop I need the program to set a value for one of those.
But how do I get the loop to increase the vertex-variable number it is setting?
In other words, I need to do something like:
force-vertex_J=wloop - 8 (and then remove the "negative" from this difference)
so that when:
wloop =8, j=0
wloop =7, j=1
...
wloop =2, j=6
wloop =1, j=7
How do I go about this?
First, what procedure will work? and secondly, how do I drop the negative.
Below is my code.
At the end of the loop, I've tabbed out an area for the storage procedure.
Thanks for your help!
Code:
#include <iostream>
int main (void) {
/* Variables */
float Xreal;
float Yreal;
float Zreal;
float Xforce;
float Yforce;
float Zforce;
float Tval;
char inZforce[64];
int check_input;
char input_buffer[160];
int wloop = 8;
/* Prompts */
/* Loop */
while (wloop > 0)
{
wloop--;
/* Get real */
printf("Real-Point values in (x, y, z) ");
fgets(input_buffer, 160, stdin);
check_input = sscanf(input_buffer, "(%f,%f,%f)", &Xreal, &Yreal, &Zreal);
while (check_input !=3) {
//Improper format
printf("Improper format.");
return(0);
};
/* Get Z coordinate of force */
printf("Zforce value: ");
fgets(inZforce, 64, stdin);
Zforce=strtof(inZforce, NULL);
/* Computation */
Tval=Zforce/Zreal;
Xforce=Tval*Xreal;
Yforce=Tval*Yreal;
/* Output Display */
printf(" \n");
printf("Forced Point: (%.3f, %.3f, %.3f) \n",Xforce,Yforce,Zforce);
printf("Real Point: (%.3f, %.3f, %.3f) \n",Xreal,Yreal,Zreal);
printf("T-value: %.3f \n",Tval);
printf(" \n");
/* Save vertex value in storage */
/* STORAGE PROCEDURE HERE */
} /* End Loop */
/* Final Display */
printf("Vertex creation complete. \n");
/* Then display Force-Vertex 0-7 coords */
return(0);
}