I am a newbie in programming and I'm using visual studio.
i typed in this

#include <stdio.h>
#include <conio.h>
#define PI 3.1416 

void main(void)

float radius, circumference, area;

radius = 2.5;

circumference = 2 * PI * radius;

area = PI * radius * radius;

printf("radius of a circle = %f cm\n", radius);
printf("circumference = %f cm\n", circumference); 
   printf("Area = %f sq cm\n", area);  

it gives me

1>------ Build started: Project: tryagn, Configuration: Debug Win32 ------
1>Build started 21/04/2012 5:31:18 PM.
1>  Touching "Debug\tryagn.unsuccessfulbuild".
1>  tryagain.c
1>d:\vc\chap2\sln\tryagn\tryagain.c(4): error C2449: found '{' at file scope (missing function header?)
1>d:\vc\chap2\sln\tryagn\tryagain.c(14): error C2059: syntax error : '}'
1>Build FAILED.
1>Time Elapsed 00:00:00.29
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What is wrong with it?

Edited by pyTony: Make sure to post to correct forum, use code from menu for code blocks

Votes + Comments
You're a newb in comminc
5 Years
Discussion Span
Last Post by BobS0327

I'm not sure if visual studio supports a deprecated library like conio.h and it's functions like getch(), try removing them

also use int main instead of void main


do the following changes :

void main(void) to int main()

remove getch(), use header file "stdlib.h" and use system("pause") at place of getch()
It will hold the screen for you. (same as getch();)

use return 0 for returning nothing(same as void) in the end of the program.
return 0; is necessary because you are using an integer return type main function.


This syntax error below tells me that you have only an open brace somewhere in your code. That is, there is no corresponding closing brace. But yet I do not see this error condition in your posted code. Are you sure you posted the faulty code?

> d:\vc\chap2\sln\tryagn\tryagain.c(4): error C2449: found '{' at file scope (missing function header?)

I can only assume this second syntax error is related to the missing closing bracket.

> > d:\vc\chap2\sln\tryagn\tryagain.c(14): error C2059: syntax error : '}'

How about posting the faulty tryagain.c code?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.