Hello, I am a self taught in C, and new at that. I think its a stretch to call myself a programmer.
In the first snippet, I pass the variable seed_temp to the psat function and it works perfectly.
Code:
while (index < 101)
{
float seed_temp = 20;
do {
psat1 = calc_psat(eA, eB, eC, seed_temp, gamma_e, x1);
psat2 = calc_psat(wA, wB, wC, seed_temp, gamma_w, x2);
seed_temp = seed_temp + 0.0001;
} while (psat1 + psat2 < 760);
boil_pt[index] = seed_temp;
}
In the 2nd snippet I'm trying to pass previously calculated seed_temp rather than start at a value of 20 each pass through the do while loop. However,in the 2nd snippet using a pointer, the do while loop does not iterate to satisfy the "< 760" condition.
Code:
float seed_temp = 70;
float *p_seed_temp;
p_seed_temp = &seed_temp;
while (index < 101)
{
do {
psat1 = calc_psat(eA, eB, eC, &seed_temp, gamma_e, x1);
psat2 = calc_psat(wA, wB, wC, &seed_temp, gamma_w, x2);
*p_seed_temp += 0.0001;
}
while (psat1 + psat2 < 760);
boil_pt[index] = seed_temp;
I hope I've explained the problem clearly. I cut some code out for brevity including an obvious curly bracket. But both programs compile and run. There might be other errors but the do while loop not executing is the current one.
Thank you for any insight.
gave up trying to fix code tags