Hi I've just started learning C using K&R, and for exercise 1-15 I have to rewrite a program, using my own function. I've written the program the function and the test for it, it compiles fine using gcc, but when I run it all I get is 'Segmentation fault'.
I've tried to figure this out, but don't really have a clue as I have just started, but here is the code I have written if this explains anything :P
Code:
/* convert to Fahrenheit from Celsius function */
#include <stdio.h>
/* cfconvert function */
float cfconvert(float celsius)
{
float fahr;
fahr = (celsius * 1.8) + 32.0;
return fahr;
}
/* test conversion function */
main()
{
float c, f;
printf("Enter 'float' temperature in Celsius to convert: ");
scanf("%f", c);
f = cfconvert(c);
printf("\nCelsius: %f.1\tFahrenheit: %f.1\n", c, f);
return 0;
}
Thanks for your help in advance. Roastie.