Nested func and no main queries

Discussion in 'C Programming' started by tsdobbi, Sep 12, 2009.

  1. tsdobbi

    tsdobbi

    Joined:
    Sep 12, 2009
    Messages:
    2
    Lets start off with the fact I am not a C programmer, I am a java programmer. and got a C project dumped on me due to lack of C resources, So Ive kinda had to learn C on my own in a short period of time. Some of the program was already coded so heres the situation. Basically an old program is being migrated from one system to another and some features of said program are changing.

    As I said the basic structure of the program was already layed out, so I am trying to code in accordance with that.

    Main.pc
    config.pc
    processing.pc

    processing.pc is the problem source code.

    in it there are 3 functions (no main) each called at a different point in the Main.pc and they perform various database updates etc.

    The problem is processing.pc looks like a mess, I would like to turn a good chunk of the activities performed in each of the 3 functions in processing.pc into their own functions.

    Here in lies what I am not sure of:
    A. is it completely impossible to define nested functions in C?

    i.e.

    int process(){
    int var1= 10;

    int rc =0;

    int subprocess(int var){
    //do something
    return 0;
    }

    rc = subprocess(var1);

    if (rc = 0)
    {
    //log sucess
    }

    return 0;
    }


    B. If I define variables outside the three functions predefined in processing.pc will all the functions in the file have access to them? Note we use a make file for these files (not that I made it nor know exactly what the makefile does)

    i.e.


    //includes

    int *a;
    int *b;
    int *c;

    int func1()
    {

    a = 10;
    }

    int func2()
    {

    b = 10;
    }

    int func3()
    {

    c= 10;
    }



    Any help you can provide me will be greatly helpful.
    tsdobbi, Sep 12, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CRON
    Replies:
    24
    Views:
    200,435
    Adrienne Boswell
    Jun 20, 2006
  2. Johnny
    Replies:
    3
    Views:
    443
    Robert Kern
    Aug 23, 2005
  3. Hari Sekhon
    Replies:
    0
    Views:
    491
    Hari Sekhon
    Jun 20, 2006
  4. Vinko Vrsalovic

    int func() v/s int func(void)

    Vinko Vrsalovic, Jan 21, 2005, in forum: C Programming
    Replies:
    14
    Views:
    1,285
    Villy Kruse
    Jan 24, 2005
  5. Alex Vinokur
    Replies:
    6
    Views:
    343
    Tor Rustad
    Nov 18, 2006
Loading...

Share This Page