Call of non function

I have decalred a password function which accepts an array as parameter but while compiling, it's showing an error wherever I have called it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void password(char a[100])
{
 if(::q==1)      { cout<<"\n Enter the master password : ";  goto ENTER; }
 else if(::q==2) { cout<<"\n Enter the password of the employee : "; goto ENTER; }

 ENTER:{
 for(int x=0;;x++)
  {
   a[x]=getch();
   if(a[x]==8) { gotoxy(getx()-1,gety()); clreol; x--; }
   else if(a[x]==13) break;
   else          cout<<"*";
  }
 };
 ::q=1;
}

Wherever I have called this function it's showing an error: "Call of nonfunction."
One of the examples of the errors is below:
1
2
3
::q=1;
 password(master_password);
//Both 'q' and 'master_password' being global variables, and master_password being array of size 25. 
May be there is a variable with name "password" and compiler try to call that variable instead of function with the same name.
Just one Thing Pratik: Be careful with the goto! It's a pretty old function and makes your Project very "spaghetti-like". But it's not always a bad Option to choose :)

It does make sense in a nested Loop for example... Remember: don't use it too often and only when necessary ;)
those 2 goto's aren't doing anything anyway. natural program flow will take you to line 6.

don't use goto's. and what's all this
::q
?

surely:
q
would work? it makes your code look even more unreadable.

edit: Judging by your second code snippet you could even pass q into your function, letting you make q non-global.
Last edited on
@halfnoob
I know it's unnecessary here, but the thing was that it showed the error even before I put the goto so I thought it'd solve the problem but no.
Q would work but I guess I've declared another q somewhere hence the scope resolution operator.
Yeah i guess there might be another variable called password and it's trying to call that. I didn't think of that. Thanks! :D
Yes, there was a variable with the same name hence the problem. It's sorted out now.
all i meant was something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// pass in q
void password(char a[100], int q)
{
if(q==1)      
{ 
    cout<<"\n Enter the master password : ";
}
else if(q==2) 
{ 
    cout<<"\n Enter the password of the employee : ";
}

for(...)
{
 ....
}
Hey yeah I got you. Believe it or not, I'd initially called the parameters as youve mentioned, but cause of the errors I changed it to global.
Anyhow, could you also help me in the clreol line? I want backspace to delete the last '*' and allow me to type another character.
Topic archived. No new replies allowed.