Help with Script C++

Hello, i'm new to C++ and have just wrote this. Can someone tell me if its good or if it will work?, and how to improve it?.
thank you.

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
#include <iostream>
#include <Windows.h>
#include <string>
using namespace std;

int main ()
{
	INFO MAIN:
	string first name, middle name, last name, DOB;
	cout << "Please enter First Name: " << :n\"
	cin.get()
	cin >> first name;
	cout << "Please enter Middle Name: " << ":n\
	cin.get()
	cin >> middle name;
	cout << "Please enter Last Name: " << ":n\
	cin.get()
	cin >> last name;
	cout << "Please enter DoB: " << ":n\
	cin.get()
	cin >> DOB
	if (first name = "Murray" && middle name = "Keith" && last name = "Watson" && DOB = "21/06/98");
		{
			string username, password;
			LOGIN MAIN :
			cout << "Your information has been accepted. Please enter Username and Password";
				cout << "Enter User-Name: " << :n\;
				cin.get()
				cin >> username;
				cout << "Enter Password: " << :n\;
				cin.get()
				cin >> password;
				if (username = "murwatson972" && password = "murster972");
					cout << "Succesful Login" << :n\
					goto MAIN
				else 
					cout << "Bad User-Name\Password. Access denied" << :n\;
					goto LOGIN MAIN;
					}
	else
		{
			cout << "Your information was not accepeted. Access Denied" << :n\;
			cin.get()
			goto INFO MAIN;
			}
			
		
	
Last edited on
INFO MAIN:
string first name, middle name, last name, DOB;

gotos are really described as bad, and should not be used.
also, line 2 will not compile, as "name" does not name a type. you must make it "first_name" or "firstname"(without quotes),etc...
also, in lines 10-12, you misplaced the quotes, which would lead to compile errors.
a correct way of doing it:
1
2
cout<<"Hello, world.\n";
cin.get();


Aceix.
Last edited on
if it will work
Try to compile and you will know
if its good
No. Some problems:
1) You cannot have spaces in indentifiers.
2) :n\ where did you get that construct. It is completely wrong
3) Why are you using cin.get() here?
4) Do not use goto. Structure your code instead.
5) Your program is unfinished and will not compile

and how to improve it?.
Start with reading tutorials
http://www.cplusplus.com/doc/tutorial/
http://www.learncpp.com/
Then start with some novice exercises:
http://www.cplusplus.com/articles/N6vU7k9E/
cin.get() only grabs a single character. You might want to use cin.getline() instead.
You're missing a lot of ; (semicolons) at the end of statements.

":n\

should be

'\n';

Note that it's '\n' (character) not "\n" (string).

Get a good compiler like codeblocks and compile your program, it will give you a list of all the errors and error messages that you can google for hints as to what went wrong. And if you can't figure it out you can post the code here and tell us what error message you get on what line.
Last edited on
By the way what works for me is to study each section of the tutorial until you understand it, googling anything that is too vague, then when you have a grasp on it write it out a condensed version of it in a notebook in your own words. This will help burn it into your memory and act as a handy reference as you learn (make sure to include the exact syntax for things like assignments, the logical rules of different types of code etc). It really helps.
Topic archived. No new replies allowed.