program compiles... doesn't work

Discussion in 'Programmer's Corner' started by dmccormick84, Mar 19, 2010.

  1. dmccormick84

    Thread Starter New Member

    Mar 3, 2010
    11
    1
    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
     
  2. S_lannan

    Active Member

    Jun 20, 2007
    247
    2
    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.
     
    dmccormick84 likes this.
  3. someonesdad

    Senior Member

    Jul 7, 2009
    1,585
    141
    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.
     
    dmccormick84 likes this.
  4. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    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.
     
    dmccormick84 likes this.
  5. dmccormick84

    Thread Starter New Member

    Mar 3, 2010
    11
    1
    er... ummm... tried to paste the code and couldn't do it. Typed (mistyped!)) it into the post! Sorry
    dmccormick :eek:
     
  6. dmccormick84

    Thread Starter New Member

    Mar 3, 2010
    11
    1
    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:
     
  7. dmccormick84

    Thread Starter New Member

    Mar 3, 2010
    11
    1
    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:
     
  8. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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
    Code ( (Unknown Language)):
    1.  
    2. 10 be born
    3. 20 live
    4. 30 die
    5.  
     
    dmccormick84 likes this.
Loading...