Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Declaring Variables and Includes
Page 1 of 1

PostPosted: Tue Apr 15, 2003 1:11 pm
by cable_guy_67
Being relatively new to C and VERY new to Pocket C I wondered if someone could give me some info on just how the include process and variable declarations work.

As I understand it the order of the includes is important only if one include declares a variable or function before the next uses it.

Does this mean I can look at my includes like this : At the point of the include it is like the code contained in the included file is at that point?

For example :

// some other code
string B;
int A;

include mark.h
include mark.c

main(){ // etc. etc...
int C;
str D;
C=func() + funky();
D=func() + funky();
}
end of file

//mark.h

func(){
B=10;
}

end of file

//mark.c

funky(){
A=8;
}

end of file

I know it is a stupid example that really just runs circles around itself but I'm trying to understand the importance of order. So the compiler would see code as:

// some other code
string B;
int A;

//mark.h

func(){
B=10;
}
//mark.c

funky(){
A=8;
}

main(){ // etc. etc...
int C;
str D;
C=func() + funky();
D=B +A;
}
end of file


This would result in an integer of C=18 and D="108" due to Pocket C adjusting the variable type to fit. Where would be the proper place to declare the variables for the functions? Are the global declarations the ones outside of the main()? I'm assuming the local variables are the ones inside of a given function. If they are outside of the function do they not exist unless they are global? Does it matter what order the variables are declared? Would it cause an error is D was declared before C? Thanks for clarification in this.

Mark

PostPosted: Tue Apr 15, 2003 1:48 pm
by jstadolnik
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
Does this mean I can look at my includes like this : At the point of the include it is like the code contained in the included file is at that point?
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

The entire include file is effectively inserted at the point of a #include statement.

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
This would result in an integer of C=18 and D="108" due to Pocket C adjusting the variable type to fit. Where would be the proper place to declare the variables for the functions? Are the global declarations the ones outside of the main()? I'm assuming the local variables are the ones inside of a given function. If they are outside of the function do they not exist unless they are global? Does it matter what order the variables are declared? Would it cause an error is D was declared before C? Thanks for clarification in this.
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Global and local variables must be declared before they can be used.

Functions must also be declared before they can be used, however you can use function prototypes to declare functions before you actually define them.

int foo(); //prototype declaration
int bar() { return(foo()); }
int foo() { return(1); }; //function definition

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm