Multiple misuses and misunderstandings in code syntax

Hello, I am "Nicholas" from IRC, I often "annoy" people with my overbugged code, guys at IRC were solving another problem so I felt uncomfortable to interrupt, here it is, I want to write "dumb" program that has different commands which do different things (calculators, beepers, quiz, etc) but.. I have multiple syntax errors, I had different versions of code but I tend to rush it and try everything I can come up with (guys told me that its bad, but since I have no debugging skills that's all I can do) for example beep command was running fine, it was repeating two times and I could not do beep again, also I believe I could only do "beep" if I didn't typed "commands" yet, so current version of code is probably most messed up, sorry. so I just want to fix current problems I just want it to do beep 2 times once you type it, and I want it to be performed almost flawlessly, be advised that I will add more commands later.

Its 2AM and I wrote this thread in rush, if I left something off please ask me.

But. I might be asking for too much, be sure to change code so I can releate to past code and if you cover some topics that I might not know, please tell me proper names of those so I can look it up in google and learn (try not to use advanced techniques), okay - Thanks a lot! and yeah, its kinda prank program. (not virus/annoying software, don't include something that will get user uncomfortable, irritated, etc)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 #include <iostream>
#include "ConsoleColor.h"
#include <string>

int sChoice();
void beepitfgt();

using namespace std;

string s; // string 0
string s1; // string 1

boolean helpUser = false;
int main()
{
	cout << green << "*** Welcome to  Dumb Console Program 0.0.0, please, type 'commands' for help. ***" << endl;
	cin >> s; 
	sChoice();
}

int sChoice()
{
	
	{
		if (s == "commands" || s == "command" || s == "cmd" || s == "help" || s == "HELP ME RIGHT NOW!" || s == "heeeeeeeeeeeeeelp")
		{
			helpUser = true;
			cout << green << "COMMANDS: calculator, beep" << endl; // Ignore calculator for now.
		}
		else if (s == "beep" && helpUser == true)
		{
			while (helpUser == true)
			{
				cin >> s1;
			}
			for (int beepCounter = 0; beepCounter != 2; beepCounter++){
				cout << "\a" << endl;
				break;
			}
		}
		else 
		{
			cout << red << "What?!" << endl;
	
			while (true)
			{
				system("PAUSE");
			}
			return 0;
		}
	}
}

void beepitfgt() // Don't even know why its here... probably was planning to make code more organised.
{
	
}


If you are more github person, here it is: https://github.com/NicholasM10/dcp
Last edited on
Nicholas, how is the function sChoice going to get a value for 's' It isn't passed to it from main(), and it isn't declared within sChoice?

Also, that isn't how you declare a boolean. It's bool, not boolean.
Last edited on
Nicholas: i am happy to see you attempting to code. and well your doing a couple of things wrong here like mentioned above so i thought i would give you some advice.

when new at programming don't try to code everything up at once, write some code and build then if it builds continue to the next part. if you wrote something like this and built it the compiler would tell you that 'boolean' is wrong. this is just a tip to help you in your quest for the programming overlords ;}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <string>

int sChoice();
void beepitfgt();

using namespace std;

string s; // string 0
string s1; // string 1

boolean helpUser = false;
int main()
{
	
}

int sChoice()
{

}

void beepitfgt() // Don't even know why its here... probably was planning to make code more organised.
{

}
Ok, I got that habit from Java, I fixed it but nothing changed. console still does not recorgnises "beep" command and it still does not beep twice.
Ok so you want to have it beep as well. an other tip i am going to give you. anything you wan someone else has asked it on the internet before you. try looking it up on the google machine.

i say that because in the code you have given. you don't seem to actually call code that beeps for you. well it might be line 27 but not all systems work the same/ i am pretty shure windows takes commands lithe that.

if your one windows this thread might be of help to you.
http://stackoverflow.com/questions/4060601/make-sounds-beep-with-c

i tested the test code the guy gives and it works for me.
Topic archived. No new replies allowed.