User Tag List

Results 1 to 3 of 3

Thread: (C++) Calling Functions

  1. #1
    (C++) Calling Functions

    User Info Menu

    (C++) Calling Functions

    Tut by TheEliteOne

    Calling Functions in C++

    Lets say we want a title, like this:

    TheEliteOne's Example!
    at the top of the screen, but we don't want to type in cout<<"TheEliteOne's Example!\n\n"; every time. We can use a function and call it every time we want to. Like this:

    Code:
    #include <iostream.h>
    void title()
    {
        cout<<"TheEliteOne's Example!\n\n";
    }
    void pause()
    {
        system("pause");
    }
    void cls()
    {
        system("cls");
    }
    int main()
    {
        First:
              cls(); //Calls are cls function.
          title(); //Calls are title function.
          cout<<"See.. not that hard right?\n\n";
          pause(); //Calls are pause function.
          goto First;
    }
    I don't know about but I would rather type in some thing like "title();" than "cout<<TITLE OF YOUR PROGRAM\n\n"; " every time I wanted to ;) hope it helped.

    If you have an idea on a PSP related program that is ran on Windows PM me with some information on your idea please.

  2. #2
    (C++) Calling Functions

    User Info Menu

    Re: (C++) Calling Functions

    Lol, I need some help with this:

    It's an autotyper...
    What I'm trying to make this one do is
    • Ask you 'How many times should the spamming loop for?'
    • How much delay/wait/sleep time in between messages?
    • How many lines you want spammed
    • Requests what you want in spammed and stores it in the corresponding cell of the array
    • Spams!!
    • Future plans: Make GUI(wayyy in future), Add a hotkey to stop / pause the program such as ctrl + s or F8

    What it does right now:
    • SUCKS!
    Code:
    #include <iostream>
    #include <windows.h>
    #include "SendKeys.h" //http://www.codeproject.com/KB/cpp/sendkeys_cpp_Article.aspx
    
    using namespace std;
    
    int MainLoop,TimesSpammed,ActualTimesSpammed,LinesSpammed,WhichSpamLine,Wait,null1,null2;
    const char *LinesToBeSpammed[LinesSpammed];
    
    void defvar()
    {
    const char *LinesToBeSpammed [LinesSpammed];
        printf("How much wait time do you want in between spammed messages?\n(This is in milliseconds, to convert multiply how many seconds times 1000)\n");
        cin >> Wait;
        printf("How many lines would you like to spam?\n");
        cin >> LinesSpammed;
        
        for (;LinesSpammed = *LinesToBeSpammed[LinesSpammed]; LinesSpammed++)
        {
            cout << "Please type what you would like spammed for line number "<<LinesSpammed<<".\n)";
            cin >> LinesToBeSpammed[LinesSpammed];
        }
        
    return 1; //will this close it?
    }
    
    
    int main()
    {
        
        
        const char *LinesToBeSpammed [LinesSpammed];
        printf("How many times would you like to spam?\n");
        cin >> TimesSpammed;
    
       if (TimesSpammed==0) 
       {
       printf("Please enter a number higher then 0\n");
       }
       else
       {
       int defvar();    
       } 
       
        Sleep(Wait); //seconds or milliseconds? I keep forgetting.
        
        for (;ActualTimesSpammed != TimesSpammed;ActualTimesSpammed++)
        {
        SendKeys("{DELAY=Wait}LinesToBeSpammed[ActualTimesSpammed]~");
        //ActualTimesSpammed++;
        }
    }
    If you have another autotyper, simpler or not hopefully more complex, please post, I want to learn from that.
    Quote Originally Posted by Epic of HITB
    get... 1) a mini fridge | 2) A toilet installed in your room | 3) a closet full of non-perishable foods | 4) Lyscol ( who needs showers anyway?) | 5) tons of books articles lectures zines etc etc

    Dont leave your room...EVER... AND I MEAN EVER
    Damned six line limit! *NERD RAGE*

  3. #3
    (C++) Calling Functions

    User Info Menu

    Re: (C++) Calling Functions

    I don't know sorry =/

    If you have an idea on a PSP related program that is ran on Windows PM me with some information on your idea please.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •