An Access violation(segmentation fault) raised in your program

Whenever I run this program, I get an error saying "An Access violation(segmentation fault) raised in your program".This is my first C++ Program with multiple functions. Please help.
Using Dev C++ on Windows 7 64bit


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
float c;
float f;

float ftoc(float f) //convert fahrenheit to celsius
{
	c=(5/9)*(f-32);
	return (c);
}

float ctof(float c) //convert celsius to fahrenheit
{
	f=(9/5)*(c+32);
	return (f);
}

main()
{
	int a;
	printf("To convert Celsius to Fahrenheit, press 1\nTo convert Fahrenheit to Celcius, press 2\n");
	scanf("%d", a);
	
	if ( a==1 )
	{
		printf("\nEnter the value in Celsius.\n");
		scanf("%f", c);
		ctof;
		printf("The temperature in Fahrenheit is %f",f);
	}

	else if ( a==2 )
	{
		printf("\nEnter the value in Fahrenheit.\n");
		scanf("%f", f);
		ftoc;
		printf("The temperature in Celsius is %c", c);
	}
	
	else
	{
		printf("invalid value");
	}
	getchar();
}
Line 26 should be scanf("%f", &c) ;

Line 34 suffers a similar problem and so does line 21.

Lines 27 and 35 don't do anything.
Last edited on
Thanks, that solved the problem. Just figured out that I had to include the parameters while calling the function.
Last edited on
Topic archived. No new replies allowed.