Thread: First Program

Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    Astralblack's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    0
    My Mood
    Dead

    First Program

    Hello all just wrote a basic program that's main purpose is too take in information for said account and display it back to you.

    Code:
    #include <iostream>
    #include <windows.h>
    #include <stdio.h>
    #include <string>
    
    class Account 
    {
    
        public:
        std::string name, pin;
    
        void Register()
        {
            std::cout << "Please enter you're name: " << std::endl << std::endl;
            std::getline(std::cin, name);
            std::cout << "Please enter a pin: " << std::endl;
            std::getline(std::cin, pin);
            system("cls");
            std::cout << "Thank you for registering  " << name << std::endl;
            Sleep(2000);
            std::cout << "Please wait a moment while we take you to you're account " << std::endl;
            Sleep(7000);
    	Login();
        }
    
        void Login()
        {
            std::cout << "Account information: " << std::endl << std::endl;
    		std::cout << "Name : " << name << std::endl;
    		std::cout << "Pin  : " << pin << std::endl;
            Sleep(3000);
    		std::cout << "Thank you for testing this system" << std::endl;
    		std::cout << "goodbye " << std::endl;
    		Sleep(1000);
    
        }
    
    };
    
    int main()
    {
        std::cout << "Hello welcome!" << std::endl << std::endl;
        Account accountobject;
        accountobject.Register();
    
        return 0;
    }
    Last edited by Astralblack; 03-10-2017 at 06:21 AM.

  2. #2
    D E R A N G E D's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Location
    H I G H E R
    Posts
    115
    Reputation
    24
    Thanks
    26
    Denkz for the dank code

  3. #3
    PraiseCthulhu's Avatar
    Join Date
    Feb 2017
    Gender
    male
    Posts
    10
    Reputation
    10
    Thanks
    3
    For fucks sake. It's "your account" and "your name", not "you're account" or "you're name"...
    Last edited by PraiseCthulhu; 03-10-2017 at 12:22 PM.

  4. The Following User Says Thank You to PraiseCthulhu For This Useful Post:

    Silent (05-08-2017)

  5. #4
    Astralblack's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    0
    My Mood
    Dead
    lel opps. sowwy

  6. #5
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by PraiseCthulhu View Post
    For fucks sake. It's "your account" and "your name", not "you're account" or "you're name"...
    Chill bro.

  7. #6
    PurpleOldMaN's Avatar
    Join Date
    Jul 2014
    Gender
    male
    Location
    Giveaway section
    Posts
    828
    Reputation
    22
    Thanks
    60
    Noice, now extend it
    bananas float in water

  8. #7
    Astralblack's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    0
    My Mood
    Dead
    I plan to add more complex functions to it the more I l learn. I will release it when I feel it is up to my standards and when it does what my goals intended it to do.

  9. #8
    Wolf22j's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Posts
    5
    Reputation
    10
    Thanks
    0
    My Mood
    Cold
    You should use "Hello world\n" or "Hello world\n\n" for double lines. std::endl flushes the stream which makes it slow compared to just "\n"

  10. #9
    Astralblack's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    0
    My Mood
    Dead
    I was not aware of this, thank you. I will use that in my future code.

  11. #10
    Nimboso's Avatar
    Join Date
    Sep 2015
    Gender
    male
    Posts
    554
    Reputation
    21
    Thanks
    2,636
    Quote Originally Posted by Astralblack View Post
    I was not aware of this, thank you. I will use that in my future code.
    It doesn't matter much unless you're trying to make your code super efficient.

  12. #11
    Astralblack's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    0
    My Mood
    Dead
    To make my code secure, bug free as possible and efficient is my goal haha

  13. #12
    Fresh[Verde]'s Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    Why didn't you just use the private access specifier for your strings?
    But still good work.
    Last edited by Fresh[Verde]; 03-25-2017 at 04:51 AM. Reason: Praise

  14. #13
    Astralblack's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    0
    My Mood
    Dead
    Updated code, with some fixed things.
    Code:
    #include <iostream>
    #include <string>
    
    class Data {
    	public:
    	void Register();
    	void Login();
    
    	private:
    	std::string name, password;
    };
    
    void Data::Register(){
    	std::cout << "Please enter a name \n";
    	std::getline (std::cin, name);
    	std::cout << "Please enter a password \n";
    	std::getline (std::cin, password);
    	std::cout << std::endl;
    	getchar();
    	Login();
    }
    
    void Data::Login(){
    		std::cout << "\t Name:   " << name;
    		std::cout << "\t Password: " << password;
    		getchar();
    }
    
    int main(){
    	Data db;
    	db.Register();
    }
    Last edited by Astralblack; 03-30-2017 at 07:29 PM.

  15. #14
    EtySo's Avatar
    Join Date
    Aug 2012
    Gender
    female
    Posts
    13
    Reputation
    10
    Thanks
    0
    My Mood
    Innocent
    Congratz with ur first program though

  16. #15
    Astralblack's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    0
    My Mood
    Dead
    Thank you.

Page 1 of 2 12 LastLast

Similar Threads

  1. [TuT] First Program in C++
    By voodooflame in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 9
    Last Post: 08-25-2010, 03:04 AM
  2. Replies: 13
    Last Post: 12-28-2009, 01:13 AM
  3. My first program coded on Vb[Spammer]
    By PoP_KiLLaH in forum Visual Basic Programming
    Replies: 12
    Last Post: 11-23-2009, 09:29 AM
  4. My first program :D
    By No5cope in forum Visual Basic Programming
    Replies: 2
    Last Post: 08-25-2009, 04:23 PM
  5. [Tutorial] Your first program
    By akimoko in forum C++/C Programming
    Replies: 10
    Last Post: 06-23-2007, 12:58 PM