Nested func and no main queries

Joined
Sep 12, 2009
Messages
2
Reaction score
0
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top