How to Generate Random Passwords with Alphanumeric and special characters ?

     char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+";

  //  int passwordLength = 10; // Change this value to set the desired length of the password
    char generatedPassword[10 + 1];
    int i;

    lr_save_string("""GeneratedPassword"); // Clear any previous values

    // Generate random characters for the password
    for (i = 0; i < 10; i++) {
        int index = rand() % (sizeof(charset) - 1);
        generatedPassword[i] = charset[index];
    }

    generatedPassword[10] = '\0'// Null-terminate the string

    lr_save_string(generatedPassword, "GeneratedPassword"); // Save the generated password as a parameter

    lr_output_message("Random password: %s", generatedPassword);