Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Nested func and no main queries

Reply
Thread Tools

Nested func and no main queries

 
 
tsdobbi tsdobbi is offline
Junior Member
Join Date: Sep 2009
Posts: 2
 
      09-12-2009
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
func() in implementation and func (100, 200, 300) in calling Alex Vinokur C Programming 6 11-18-2006 08:08 AM
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
difference between import from mod.func() and x=mod.func() Hari Sekhon Python 0 06-20-2006 08:07 AM
What's the difference between built-in func getattr() and normal call of a func of a class Johnny Python 3 08-23-2005 08:28 AM
int func() v/s int func(void) Vinko Vrsalovic C Programming 14 01-24-2005 08:07 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57