for (i = 0; i<100; i++)
{
temp_f = (1.8 * i) + 32; // convert from C to F
result = (5 * temp_f) + 2297;
result = result / 2457;
result = 325.8*sqrt(result);
fprintf(outputFileptr ,"%3d %8.4f\n", i, result); /*prints to a file*/
printf("%3d %8.4f\n", i, result);
Line 25: Where do you initialize (open) outputFileptr?
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
// ConsoleApplication6.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <stdlib.h> /* For exit() function */
#include <math.h>
int main()
{
float temp_c, temp_f, result;
int i;
FILE *outputFileptr ;
outputFileptr = fopen("new.txt","w");
printf("%s","Temperature(C) Speed\n");
fprintf(outputFileptr,"%s", "Temperature(C) Speed\n");
for (i = 0; i<100; i++)
{
temp_f = (1.8 * i) + 32; // convert from C to F
result = (5 * temp_f) + 2297;
result = result / 2457;
result = 325.8*sqrt(result);
printf("%3d %8.4f\n", i, result); /*print to the console*/
fprintf(outputFileptr, "%3d %8.4f\n", i, result);
}
fclose(outputFileptr);
getchar();
getchar();
return 0;
}