Go to Post Most of all, I long to give others a chance to experience what I did with FIRST, to give people from my home town that opportunity, because FIRST really is that once in a lifetime opportunity that so many people dont get a chance to be a part of. It shouldnt be that way. - Jacqui Sutton [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 14-10-2004, 14:22
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: i would like your opinion on my programs

Quote:
Originally Posted by CmptrGk
the only reason i used the doubles was because the i wouldnt get any results for some larger numbers. i will also try to make seperate functions for each part (once i learn how to use them). and i did not know that you could instalise(is this the correct term) variables within functions.
Yeah, you can declare (your words was correct, if slightly misspelled ) a variable inside a function. This is greatly preferred by most authors, as it helps to keep everything modular and reusable. A variable declared inside a function, as foosFavorite is in this example...
PHP Code:
void foo(void);
void bar(void);

int main(int argcchar *argv[])
{
   
foo();
   
foosFavorite 1// Compile error - foosFavorite doesn't exist
}

void foo(void)
{
    
// Decalare a variable
    
int foosFavorite;
    
foosFavorite 1// Fine

    // Call bar()
    
bar();
}

void bar(void)
{
   
foosFavorite = -100// Compile error - foosFavorite doesn't exist

...is visible only to that function. For instance, in my example here, foosFavorite is able to be used only by foo(), not by the function which called it nor by the function foo() calls.

In C, you have to declare all local variables at the beginning of the function. No other executed line can come before them; comments are fine, but no function calls or anything. C++ relaxes this rule, so if you're actually using a C++ compiler, it will let you get away with not having declarations at the beginning. Be warned though; the MPLAB compiler only accepts at the beginning.
__________________


Last edited by Ryan M. : 14-10-2004 at 14:24.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
dash programs suneel112 Programming 12 26-01-2005 14:44
IFI's Serial Programs Doing Funny Stuff? Ian W. Programming 4 18-03-2004 21:43
Whats your honest opinion? Sean General Forum 50 17-04-2003 21:05
Dashboard programs and the char variable Ian W. Programming 13 26-06-2002 02:07
Dashboard programs archiver 2000 6 23-06-2002 23:10


All times are GMT -5. The time now is 05:25.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi