Password programme

Hi, i keep getting this error message when i compile in Dev C++. [Error] 'function' does not name a type.

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
  #include <iostream>
#include <string>
#include <iomanip>


function validate()
{
  var a=documents.forms["yourpasswordfieldname"].value;
  var b=documents.forms["yourconfirmpasswordfieldname"].value;
  
  {
  	if(!(a==b))
    	{
			cout<<"passwords are not matching";
    		valid=false;
    	}
    
	else 
		{
			valid=true;
		}
  }
  
  system("pause");// this will hold the screen so that display can be seen

return 0;
}
I dont think var is a c++ type try using just string instead of var.
hi i tried that. it gives the same error and highlights the statement function validate()
var a=documents.forms["yourpasswordfieldname"].value; this is javascript not c++.

Where you have function you would but the return type in this case int since you are returning 0. You will also need a main function with a return type of int.
i replaced var with int. same error. Can anyone write out the code how it should be for me please? I am new to C++ and this is killing me.
You may have done that but you didn't remove the javascript, fix the function return type, or add the main function.
When i added the main function i ended up with a lot more errors.
I would suggest reading up on basic data types and functions before attempting to use them. None the less try and use an arbitrary language mixed with c++. Anyways, you never even defined "valid" so that is another error. You have a bit to learn.


Please refer to these first:
http://www.cplusplus.com/doc/tutorial/
http://www.learncpp.com/
ok thanks
You don't declare variables and functions by declaring them with "var" and "function". You declare variables with their type, and functions with their return type.
Topic archived. No new replies allowed.