program compiles... doesn't work

Thread Starter

dmccormick84

Joined Mar 3, 2010
11
Hi all... this bit of code compiles fine with mingW, but gives me no output!

#include <stdio.h>
#include <math.h>
#include <float.h>
#include <stdlib.h>

long cap_reac();
long c, freq, a;

int main()
{
printf("input the cap value...\n");
scanf("l%", &c);
printf("input the frequency...\n");
cap_reac();
cap_reac()
}
{ long c, freq, a;
a =(159.2/(c * freq));
printf("%l equals... " , a);
}

{

:( dmccormick84
 

S_lannan

Joined Jun 20, 2007
246
We've got quite a few problems here.

You define some global variables then try to define them again within the function.
The prototype says the function is a long and where you define the function you havent specified what type it is.
You've closed a bracket where the function definition is, you should have closed it at the end of main().
There is no scanf call to get the frequency from the user.

Needs a bit of work.
 

someonesdad

Joined Jul 7, 2009
1,583
Before you submit code for a question, make sure it compiles. This has too many mistakes in to compile. Also use the {code} ... {/code} formatting (replace curly braces with square braces) to avoid having the board's software destroy the formatting. Nobody likes looking at horribly-formatted code.
 

beenthere

Joined Apr 20, 2004
15,819
After compile time errors come the run time errors. The latter don't generate messages, just black screens or lockups. Then you get to use (or write) a debugger.
 

Thread Starter

dmccormick84

Joined Mar 3, 2010
11
We've got quite a few problems here.

You define some global variables then try to define them again within the function.
The prototype says the function is a long and where you define the function you havent specified what type it is.
You've closed a bracket where the function definition is, you should have closed it at the end of main().
There is no scanf call to get the frequency from the user.

Needs a bit of work.
er... ummm... tried to paste the code and couldn't do it. Typed (mistyped!)) it into the post! Sorry
dmccormick :eek:
 

Thread Starter

dmccormick84

Joined Mar 3, 2010
11
Before you submit code for a question, make sure it compiles. This has too many mistakes in to compile. Also use the {code} ... {/code} formatting (replace curly braces with square braces) to avoid having the board's software destroy the formatting. Nobody likes looking at horribly-formatted code.
Thanks for excoriating my sorry arse, someonesdad. Tried to paste the original code... wouldn't accept it. So... I mistyped it!! Sorry, will repost as soon as I figure out how to attach stuff...
dmccormick84:confused:
 

Thread Starter

dmccormick84

Joined Mar 3, 2010
11
After compile time errors come the run time errors. The latter don't generate messages, just black screens or lockups. Then you get to use (or write) a debugger.
WRITE a debugger????? Even my 'hello, world' is crappy, beenthere! I did invoke the -Wall option and got some very strange and cryptic messages!
BTW... I screwed up on the post... will repost ASAP. Thanks...
dmccormick84:eek:
 

retched

Joined Dec 5, 2009
5,207
to pates code into a post, You have to surround it in ]code[ and ]/code[ delimiters

(reverse the []'s)

So, if I type:
[ code ]
10 be born
20 live
30 die
[ /code ]
just be sure to remove the spaces between the ['s and code

It will look like this
Rich (BB code):
10 be born
20 live
30 die
 
Top