'isupper': identifier not found

I am new to the form.h programming in VS 2016, but I just can't figure out why I have the above error when building the solution. The codes are:


private: System::Void login_button_Click(System::Object^ sender, System::EventArgs^ e)
{
const int SIZE = 80;
const int MIN = 6;
using namespace std;

char password[SIZE];
bool minLength = false;
bool hasUpper = false;
bool hasLower = false;
bool hasNumbers = false;


String^ nowString = password_txt->Text;

if (nowString->Length >= MIN)
{
minLength = true;
}

for (int i = 0; i < nowString->Length; i++)
password[i] = static_cast<char>(nowString[i]);


for (int i = 0; i < nowString->Length; i++)
{
if (isupper(*password)) //determines if character is uppercase
hasUpper = true;
if (islower(*password)) //determines if character is lowercase
hasLower = true;
if (isdigit(*password)) //determine if character is digits
hasNumbers = true;
}


}


I am trying to validate a password that a user enters. In .cpp , this is the headers that I put:

#include "MyForm.h"
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <msclr/marshal_cppstd.h>
#include<cstring>



Any suggestion on why it is giving me the error 'isupper': identifier not found?

Can you post a complete example that reproduces the problem? That will make it much easier to help you.
Also, please use code formatting tags. You can edit your post and add [code] and [/code] around your code.

By the way, this isn't standard C++, this is C++\CLI, or Microsoft's version of managed C++. The mixing of char arrays with String objects you have implemented is quite odd, and probably error-prone.

I agree with Ganado that it's not a good idea to mix C++ chars with C++ CLR String.
Much easier:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
System::Void login_button_Click(System::Object^  sender, System::EventArgs^  e) 
  {
    const int MIN = 6;

    bool minLength = false;
    bool hasUpper = false;
    bool hasLower = false;
    bool hasNumbers = false;

    if (password_txt->Text->Length >= MIN)
    {
      minLength = true;
    }

    for each(char ch in password_txt->Text)
    {
      if (Char::IsUpper(ch))
        hasUpper = true;
      else if (Char::IsLower(ch))
        hasLower = true;
      else if (Char::IsDigit(ch))
        hasNumbers = true;
    }
  }
Thanks all for your comment ...

Thomas, in line 15, the 'in' statement, is that a variable type?
No, "in" would be a keyword of sorts. It's just part of the foreach syntax of C++ CLI code, to allow you to iterate over every element in password_txt->Text

See: https://stackoverflow.com/questions/851881/how-to-use-foreach-in-c-cli-in-managed-code

C++11 has foreach loops as well, they look like this:
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <string>
int main()
{
    std::string text = "henlo";
    for (char c : text)
    {
       std::cout << c << '\n';
    }
}


Last edited on
Topic archived. No new replies allowed.