why wont this compile?

i know im should not ask for help for little things like this but i need help heres my code!

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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <string>
void skipline(),options(),input();

using namespace std;



int main()
{
	int ans;
	int cal;
	float number,number2;
	

	cout << "Log in\n";
	skipline();
	
	cout << "Password:";

	
	std::string In_Buffer;

    std::getline( std::cin, In_Buffer, '\n' );



    if( In_Buffer.compare( "admin" ) == 0 )
    {
	  skipline();
	  system("CLS");
	  cout << "Welcome!\n";
	  skipline();
	
	 }

	options();
	skipline();
	input();
	cin >> ans;
	if(ans==1)
	{
	system("CLS");

	cout << "Calculator\n";
	skipline();
	cout << "1.Addition" << endl;
	skipline();
	cout << "2.Subtraction" << endl;
	skipline();
	cout << "3.Multtply" << endl;
	skipline();
	cout << "4.Division" << endl;
	skipline();
	cout << "5.Square root" << endl;
	skipline();
	cout << "6.End program" << endl;
	input();
	cin.get();
	
	cin >> cal;
    if(cal==1)
	{
	skipline();
	cout << "Addition";
	skipline();
	skipline();
	cout << "Enter first number:";
	cin >> number;
	skipline();
	cout << "Enter secound number:";
	cin >> number2;
	skipline();
	cout << "Answer:"<< number + number2;
	skipline();
	}

	if(cal==2)
	{
	skipline();
	cout << "subtraction\n";
	skipline();
	cout << "Enter first number:";
	
	cin >> number;
	skipline();
	cout << "Enter secound number:";
	
	cin >> number2;
	skipline();
	cout << "Answer:"<< number - number2;
	cin.get();

	}

	if(cal==3)
	{

      skipline();
		cout << "multiplying\n";
		skipline();

		cout << "Enter first number:";
		cin >> number;

		skipline();

		cout << "Enter secound number:";
		cin >> number2;

		skipline();
		skipline();
		cout << "Answer:" << number * number2;
		skipline();

		cin.get();
	}

	if(cal == 4)
	{
	skipline();
	cout << "Division";
	skipline();
	skipline();
	
	cout << "Enter First number:";
	cin >> number;
	skipline();
	cout << "Enter secound number:";
	cin >> number2;

	skipline();
	cout << "Answer:"<< number / number2;
	skipline();
	cin.get();
	}


	if(cal == 5)
	{
	skipline();
	cout << "Enter number:";
	cin >> number;
	skipline();
	
	cout << "Answer:" << sqrt(number); /*finds the square root of said number =)*/
	cin.get();
	}


	if(ans == 6) /*if /person inputs 6 exit program*/
	{
		return 0;
	}

	if(cal > 6) /*if person enters a number larger than 6 out put error message*/
	{
		cout << "ERROR";
	}

	

	}


	}


	cin.get();
}

void skipline()
{
	cout << "\n";
}

void options()
{
	cout << "1.Calculator";
	skipline();
	cout << "2.Web Browser";
	skipline();
	cout << "3.Hack Tools";
	skipline();
	cout << "4.Exit";
}
void input()
{
	cout << ":";
}


error code

------ Build started: Project: latest practice review, Configuration: Debug Win32 ------
latest practice review.cpp
latest practice review.cpp(173): error C2143: syntax error : missing ';' before '.'
latest practice review.cpp(173): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
latest practice review.cpp(174): error C2059: syntax error : '}'
latest practice review.cpp(174): error C2143: syntax error : missing ';' before '}'
latest practice review.cpp(174): error C2059: syntax error : '}'
latest practice review.cpp(177): error C2143: syntax error : missing ';' before '{'
latest practice review.cpp(177): error C2447: '{' : missing function header (old-style formal list?)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Firstly, people usually don't want to debug massive bits of code and secondly, what are you trying to do exactly so I can show you how to do it, because (no offence) that is possibly the worst piece of code I have every seen.

Just a little hint for the future, don't create functions that have one line of code in them unless you have a particularly good reason to. e.g. Having a function that makes a new line...well...just don't.
Learn to read the errors.
Most of them are very self explanatory...
worst lines of codes...=( im new to c++ and i fine writing skipline() better than cout << "\n"; and how is it the worst exactly?
void skipline(),options(),input();

You can't declare functions this way. Put them all on their own line:

1
2
3
void skipline();
void options();
void input();
@learningtocode14: Calling functions has overheads and it's just not very...conventional to write it this way. It works, though it's just normally not done. Another thing, is that instead of writing another std::cout statement, you could just do something like this:

std::cout << "Hello\n"
Last edited on
@jalfor excuse me for my ignorance but what are the benefits of using std::cout << "hi"; instead of cout << "hi"; isnt it the same thing?
No, std::cout finds 'cout' in the namespace std. cout finds 'cout' in currently available namespaces (why you have 'using namespace std')
Last edited on
o i see now using namespace std; is like a package but i still dont see the benefit can you explain more?
You use namespaces to avoid multiple variables (or functions etc.) having the same name. For example using cout, if you had another function called cout it would start causing confusion as to which you're using (not just for the human) so instead you can use std::cout and someOtherNamespace::cout. The point of the "using namespace" keywords is to avoid writing out a namespaces name hundreds of times.
Topic archived. No new replies allowed.