Go Back   The UNIX and Linux Forums > Top Forums > Programming


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-10-2012
Registered User
 
Join Date: Dec 2009
Location: London
Posts: 776
Thanks: 51
Thanked 6 Times in 6 Posts
Examples, usage, help in C++ program

I have written a C++ program to perform raytracing and would want to write some functions to help the user: examples, usage, help

I am wondering how this is done. Would I just put some functions in the main program?
Sponsored Links
    #2  
Old 07-10-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,591
Thanks: 501
Thanked 2,574 Times in 2,453 Posts
How to do it depends on what you already have and what exactly you want to do.

You're vague on both, so it's difficult to help.
Sponsored Links
    #3  
Old 07-10-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,591
Thanks: 501
Thanked 2,574 Times in 2,453 Posts
Here's an example of how you'd do it in C:



Code:
int main(int argc, char *argv[])
{
        int n;
        for(n=1; n<argc; n++)
        {
                if(strcmp(argv[n], "--help") == 0)
                {
                        print_help();
                        exit(0);
                }
        }
}

    #4  
Old 07-12-2012
Registered User
 
Join Date: Dec 2009
Location: London
Posts: 776
Thanks: 51
Thanked 6 Times in 6 Posts
That's what I've done. My question is where to put the function print_help();

I do have a few functions and they are quite long. They involve
sending information to the user. I have now put them in another
file.
Sponsored Links
    #5  
Old 07-12-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,591
Thanks: 501
Thanked 2,574 Times in 2,453 Posts
Wherever you like. You can put them in the same file, or not. Just make sure to have headers for them if you put them in a different file.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Awk and Sed examples j_panky Emergency UNIX and Linux Support !! Help Me!! 7 05-14-2010 12:16 AM
How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..? laknar AIX 3 07-16-2009 05:35 AM
Checking mem usage at specific times in a program pl4u UNIX for Advanced & Expert Users 2 04-05-2009 05:26 PM
how can I find cpu usage memory usage swap usage and logical volume usage alert0919 HP-UX 3 12-02-2008 01:38 PM
usage of ftp in C program bdyjm Programming 1 10-08-2001 11:05 AM



All times are GMT -4. The time now is 07:32 AM.