How To Label!!!HELP!!!

This is a discussion on How To Label!!!HELP!!! within the C++ Programming forums, part of the General Programming Boards category; Initially i wrote basic and now C++ but i dont know how to label my scripts after i write them( ...

  1. #1
    Whats gonna happen now! himanch's Avatar
    Join Date
    Feb 2005
    Location
    Armenia
    Posts
    26

    How To Label!!!HELP!!!

    Initially i wrote basic and now C++ but i dont know how to label my scripts after i write them( in C++ language!!!)

    Can anyone help?????????

  2. #2
    Registered User Sake's Avatar
    Join Date
    Jan 2005
    Posts
    89
    How to label your programs? Can you be more specific? I can think of several things that could be called labeling.
    Kampai!

  3. #3
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    how to label my scripts after i write them
    You'll have to excuse my ignorance here but I have no idea what in the hell you are asking.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  4. #4
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    Is he possibly talking about

    Code:
    :label blah;
    
    goto label;
    that? Gotos are pretty common in Basic.

  5. #5
    Whats gonna happen now! himanch's Avatar
    Join Date
    Feb 2005
    Location
    Armenia
    Posts
    26
    Huuuuuhhhhh!!!
    i.e.
    there are two different parts in the whole script and the second part works with the result of the first part. At this point, how aM i gonna label the first part 2 work with it, in the second part of the script!!!

    IS THİS CLEAR ENOUGH!!!

  6. #6
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    IS THİS CLEAR ENOUGH!!!
    There is no need to be rude here. We are trying to help you but since you obviously don't know enough about the language in question to ask a COHERENT question do not take it out on the people trying to provide advice. Everyone has been nice here so far.

    What you are looking for is how to use functions. Look at this tutorial . It will show you what you want to know.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Yum, candy!

    Oh, and if they did in fact mean to use a label, then your example is wrong:
    Code:
    goto label;
    
    for( ;; );
    
    label:
        cout << "Now we're down here!";
    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Whats gonna happen now! himanch's Avatar
    Join Date
    Feb 2005
    Location
    Armenia
    Posts
    26
    thnkz alot but am i gonna write hte name of the label between the semicolons

    for( ; ???here??? ; );
    Hayda!!!Whats gonna happen tomorrow

  9. #9
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    I think I see what you are trying to do but it is a little hard without any code.

    Code:
    #include <iostream>
    
    using std::cout;
    using std::cin;
    using std::endl;
    
    int getInfo(void); //function declaration
    void displayHello(void); //function declaration
    
    int main() {
    
    	displayHello(); //call our first function
    	cin.get(); //keep window open
    
    	return 0;
    }
    int getInfo(void) {
    
    	int numTimes;
    
    	cout << "How many times? ";
    	cin >> numTimes;
    
    	return numTimes;
    }
    void displayHello(void) {
    
    	int maxTime;
    
    	maxTime = getInfo();
    
    	for(int i = 0; i < maxTime; i++) {
    		cout << "Hello" << endl;
    	}
    }
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  10. #10
    Whats gonna happen now! himanch's Avatar
    Join Date
    Feb 2005
    Location
    Armenia
    Posts
    26
    yep!!!!!
    this is what i am looking 4 !!!
    Hayda!!!Whats gonna happen tomorrow

  11. #11
    Whats gonna happen now! himanch's Avatar
    Join Date
    Feb 2005
    Location
    Armenia
    Posts
    26
    cant u write only


    Code:
    using namespace std;  for not to use all
                                                                                    
                                                                                   using std::cout;
                                                                                    using std::cin;
                                                                                    using std::endl;
    Dont misunderstand "andyhunter" i dnt wanna sound mean its just a question!!!
    Last edited by himanch; 02-06-2005 at 03:30 AM.
    Hayda!!!Whats gonna happen tomorrow

  12. #12
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    There are many ways to resolve a namespace in C++. This is the faq on namespaces .

    As you can see a namespace is essentially a user defined scope and as such in order to access anything within that namespace you need to bring that scope into focus. One of the ways to do that with the std namespace is to have:
    Code:
    using namespace std;
    At the begginning of your file after the includes to bring the std namespace into global scope. Another option is to just bring the objects you will be using into scope, such as say you only wanted to deal with cin, cout and endl. You would do that by placing:
    Code:
    using std::cin;
    using std::cout;
    using std::endl;
    Additionally you can use the above to methods inside of a function in order to just bring the namespace into scope for the function and not the whole program.

    And finally if you wanted to just use the objects without bringing the namespace into a larger scope you could just resolve the namespace as you went in your program:
    Code:
    #include<iostream>
    
    int main() {
    
             std::cout<<"This resolves the namespace for this object";
             std::cin.get();
             return 0;
    }
    Basically it is a style point however the whole concept of having namespaces is to prevent name clashing. Thus to just always bring the entire namespace into global scope you are defeating the whole purpose for having them. Not that this is wrong, you should just understand what you are doing.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  13. #13
    Whats gonna happen now! himanch's Avatar
    Join Date
    Feb 2005
    Location
    Armenia
    Posts
    26
    yea!!i see!!!
    Hayda!!!Whats gonna happen tomorrow

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21