A program that will be constantly changing...

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

42 Replies - 2842 Views - Last Post: 28 June 2013 - 08:47 AM

#1 =CodeBlackout=  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 24-June 13

A program that will be constantly changing...

Posted 26 June 2013 - 04:46 PM

Hello, Everyone.
This is my current program, it only has two choices so far, but I am stumped on what more to add to it. Please post what you think would be neat for it to do, preferably things that allow interface directly with the computer, maybe some remote computer things. I really have no Idea what to do with this program so far, maybe get it to do automated tasks on command or something, I would really like your input, and am raring to go. :tank:



#include<iostream>
#include<dos.h>
#include<conio.h>
#include<windows.h>
#include<string>
#include<istream>

using namespace std;






void type_text(const std::string& text)
{

	for (std::size_t i = 0; i < text.size(); ++i)
	{

		std::cout << text[i] << std::flush;


		Sleep(60);
	}
}

int main()
{
Beginning:
	type_text("Hello, what would you like to do?\n");
	std::string answer1;
	getline(cin, answer1);
	if ( answer1=="Open command prompt" || answer1=="Open CMD" || answer1=="cmd" || answer1=="Command Prompt")
      {
        system("cmd.exe");
      }


    else
{
    if( answer1=="Hack the mainframe" || answer1 =="Hack The Mainframe" || answer1=="Hack the Mainframe" || answer1 =="htm")
    {


      for(int iii=1; iii < 1000; iii++)
    {
        type_text("Hacking...");
        Beep(2000, 200);
        Beep(2000,200);
        Beep(2000, 200);
        Sleep(2000);

        if(iii==3)
           {
            type_text("\nMainframe has been hacked...\n");
            Beep(2000, 200);
            Beep(2000, 200);
            Sleep(1000);
           goto Beginning;
           }

      }

     }

}

}








Is This A Good Question/Topic? 0
  • +

Replies To: A program that will be constantly changing...

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10372
  • View blog
  • Posts: 38,411
  • Joined: 27-December 08

Re: A program that will be constantly changing...

Posted 26 June 2013 - 04:53 PM

Get rid of the gotos. They are very poor practice, and they really don't lend to clean code. Second, the conio library is a deprecated Turbo-C++ library. You should avoid using it.
Was This Post Helpful? 1
  • +
  • -

#3 =CodeBlackout=  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 24-June 13

Re: A program that will be constantly changing...

Posted 26 June 2013 - 05:00 PM

I have realized how small, and sad this code is, it's kind of embarrassing really. :withstupid:

the stupid thing didn't mean you osx nerd, your post wasn't there yet when I typed it

What would I do instead of a goto? And what is bad about it?

This is to any moderator. Follow this link, it is corrupted, or the code is bad or something.
My link
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10372
  • View blog
  • Posts: 38,411
  • Joined: 27-December 08

Re: A program that will be constantly changing...

Posted 26 June 2013 - 05:01 PM

Just use loops like everyone else. Gotos decrease readability and make it hard to follow the flow of a program. Dijkstra really makes a good case against them.

http://www.cs.utexas...02xx/EWD215.PDF

Quote

This is to any moderator. Follow this link, it is corrupted, or the code is bad or something.
My link

We're aware of this problem. It's being worked on. Just an FYI- you should check out the Site Questions and Support, and Site Feedback forums to leave this kind of feedback or ask questions about forum locations. Please avoid posting questions like that in the lounge as well. ;)
Was This Post Helpful? 1
  • +
  • -

#5 =CodeBlackout=  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 24-June 13

Re: A program that will be constantly changing...

Posted 26 June 2013 - 05:33 PM

I tried adding a do while loop to it, but it's not working. I have tried to fix it, but I just don't know what is wrong. What am I missing?
#include<iostream>
#include<dos.h>
#include<windows.h>
#include<string>
#include<istream>

using namespace std;






void type_text(const std::string& text)
{

	for (std::size_t i = 0; i < text.size(); ++i)
	{

		std::cout << text[i] << std::flush;


		Sleep(60);
	}
}

int main()
{
    bool checksee=true;

	type_text("Hello, what would you like to do?\n");
	std::string answer1;
	getline(cin, answer1);
	do {
	if ( answer1=="Open command prompt" || answer1=="Open CMD" || answer1=="cmd" || answer1=="Command Prompt")
      {
        system("cmd.exe");
        checksee=0;
      }


    else
{
    if( answer1=="Hack the mainframe" || answer1 =="Hack The Mainframe" || answer1=="Hack the Mainframe" || answer1 =="htm")
    {


      for(int iii=1; iii < 1000; iii++)
    {
        type_text("Hacking...");
        Beep(2000, 200);
        Beep(2000,200);
        Beep(2000, 200);
        Sleep(2000);

        if(iii==3)
           {
            type_text("\nMainframe has been hacked...\n");
            Beep(2000, 200);
            Beep(2000, 200);
            Sleep(1000);

           }


if(iii>=3)
{
    checksee=0;


}

      }

     }

}
}
while(!(checksee==0));
}


Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg  Icon User is online

  • member icon


Reputation: 3989
  • View blog
  • Posts: 12,304
  • Joined: 25-December 09

Re: A program that will be constantly changing...

Posted 26 June 2013 - 05:48 PM

What's the purpose of your type_text() function? Why don't you just use cout to print the string?

cout << "Hello, what would you like to do?\n";


Jim
Was This Post Helpful? 1
  • +
  • -

#7 =CodeBlackout=  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 24-June 13

Re: A program that will be constantly changing...

Posted 26 June 2013 - 05:56 PM

type_text is used to simulate typing, try putting it into your IDE, it looks really cool, and I could really use some help with the post above yours ^. :D
Was This Post Helpful? 0
  • +
  • -

#8 =CodeBlackout=  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 24-June 13

Re: A program that will be constantly changing...

Posted 26 June 2013 - 06:17 PM

Is anyone interested in giving input or helping??
:helpsmilie: :beta1:
Was This Post Helpful? 0
  • +
  • -

#9 =CodeBlackout=  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 24-June 13

Re: A program that will be constantly changing...

Posted 26 June 2013 - 06:37 PM

I keep getting emails every time someone posts, and I don't always remember to click " Stop Watching" so can someone please turn that off, it is really annoying. :2guns:
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8934
  • View blog
  • Posts: 33,455
  • Joined: 12-June 08

Re: A program that will be constantly changing...

Posted 26 June 2013 - 06:44 PM

Go to your profile, edit profile, and settings.

As for this code - typically 'share your project' is for completed or a linear line of updates to code you would like to share. Dumping out code, asking for ideas, and folks to update your code isn't really a project now is it..
Was This Post Helpful? 1
  • +
  • -

#11 =CodeBlackout=  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 24-June 13

Re: A program that will be constantly changing...

Posted 26 June 2013 - 07:22 PM

Yes it is, it is a work in progress. >_<
It is something I would like help with, that is the whole point of the website, right?
I want your guys input on a project that I am working on, I thought you would be interested in helping, I guess that you don't.
I would appreciate it if you would cooperate in the future, as the whole point of this topic is that the community would input on my project, for you to add your opinions or advice. Thank you.
Was This Post Helpful? 0
  • +
  • -

#12 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3460
  • View blog
  • Posts: 10,668
  • Joined: 05-May 12

Re: A program that will be constantly changing...

Posted 26 June 2013 - 08:00 PM

Since you are soliciting feedback:
- Pick an indent style and apply it consistently. The current illegible form of your code right now is what is giving people the impression that what you have right now is not a "project", but rather a quick and dirty "doodle".

- Use functions to break up your code into more readable pieces.

- Use descriptive variable names. iii and checksee are not very helpful in understanding what you are trying to do.

As for the point of "input on [your] project". There is a difference between input and doing your work for you. That was the point of modi123_1's post where he dissuading you from expecting people to update your code for you.
Was This Post Helpful? 1
  • +
  • -

#13 =CodeBlackout=  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 24-June 13

Re: A program that will be constantly changing...

Posted 26 June 2013 - 08:19 PM

I don't want you guys to update my code, I just want advice and ideas, like what you did, you gave me advice on my coding style(which I realize is pretty bad). I will update my code tomorrow and change some variable names, but the fact still remains, It doesn't work, and I don't know why. Thank you for posting though. :bigsmile:
Was This Post Helpful? 0
  • +
  • -

#14 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3460
  • View blog
  • Posts: 10,668
  • Joined: 05-May 12

Re: A program that will be constantly changing...

Posted 26 June 2013 - 08:44 PM

If it doesn't work, then go post again in the C/C++ forum on the thread that you started about this code base and describe what is not working, what you've tried so far to diagnose the problem and fix it.

Also I noticed that I pointed out that you should you use a do-while loop. I see that you've started going down that route, despite you having voted down my advice in the C/C++ forum.
Was This Post Helpful? 3
  • +
  • -

#15 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1359
  • View blog
  • Posts: 3,424
  • Joined: 28-November 09

Re: A program that will be constantly changing...

Posted 26 June 2013 - 09:30 PM

Learn Git and push your code to GitHub, live and breathe by it. Commit early, commit often.
Was This Post Helpful? 3
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3