0

当我构建此解决方案时,#include 库带有红色下划线,我收到以下错误:

错误 1 ​​错误 MSB8008:指定的平台工具集 (v110) 未安装或无效。请确保选择了受支持的 PlatformToolset 值。C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets 518 6 G00290342BrianVarley.c

一些帮助将不胜感激。

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <windows.h>
#include <ctime>
#include <string.h>

using namespace std;

#define MAX 80

//declaring functions
int showMenu();     
void generatePass();    
void validatePass();
int countLetters(char *,int *,int *,int *,int *);

main()
{

    int iChoice;

    // have menu appear, user makes decision, do work, reshow menu
    // do this until user enters 5

    do
    {    
        iChoice = showMenu();    

    }while(iChoice != 3);

    printf("\n\n\n");
    system("pause");


}//end of main

//Methods placed here:

//showMenu method calls program menu,either 1.generate password,2.enter password and validate. or 3.exit(close program)
int showMenu()
{
    int iChoice;

    system("cls");
    printf("\n\n\t\tWelcome to Password Generator and Validator\n\n");
    printf("\n\t\t1. Generate");
    printf("\n\t\t2. Validate");
    printf("\n\t\t3. Exit");

    printf("\n\n\t\tEnter your menu choice: ");
    fflush(stdin);
    scanf("%d", &iChoice);

    // user enters one of 3 values
    // generate,validate or exit program


    switch(iChoice)
    {
        case 1:     // generate
        {
            generatePass();
            string random_str = generatePass(15);
            printf( "\n\n\t\tYour new password is : ","%d",random_str);

            break;
        }
        case 2:     // validate
        {
            validatePass();


            break;
        }
        case 3:     // exit
        {
            printf("\n\nProgram exiting!...");
            system.exit(0);
            break;
        }
        default:
        {
            break;
        }
    }//end of switch


    return(iChoice);
} //end of showMenu


//method to generate a random password for user following password guidelines.  
string generatePass(int length)
{
    printf("\n\n\t\tGenerate Password selected ");
    printf("\n\n\t\tPassword creation in progress... ");

    srand(time(0));
    string str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!£$%^&*()_+=#@;";
    int pos;
    while(str.size() != length) {
    pos = ((rand() % (str.size() - 1)));
    str.erase (pos, 1);
    }
    return str;
}//end of generatePass method.








//method to validate a user generated password following password guidelines.
validatePass()
{
    char password[MAX+1];
    int iChar,iUpper,iLower,iSymbol,iNumber;

    //shows user password guidelines
    printf("\n\n\t\tPassword rules: ");
    printf("\n\n\t\t 1. Passwords must be at least 9 characters long and less than 15 characters. ");
    printf("\n\n\t\t 2. Passwords must have at least 2 numbers in them.");
    printf("\n\n\t\t 3. Passwords must have at least 2 uppercase letters and 2 lowercase letters in them.");
    printf("\n\n\t\t 4. Passwords must have at least 1 symbol in them (eg ?, $, £, %).");
    printf("\n\n\t\t 5. Passwords may not have small, common words in them eg hat, pow or ate.");

    //gets user password input
    printf("\n\n\t\tEnter your password following password rules: ");
    gets(password);


    iChar = countLetters(inString,&iUpper,&iLower,&iSymbol,&iNumber,&iTotal);

    if(iUpper < 2)
    {
        printf("Not enough uppercase letters!!!\n");


    }
    else if(iLower < 2)
    {
        printf("Not enough lowercase letters!!!\n");


    }
    else if(iSymbol < 1)
    {
        printf("Not enough symbols!!!\n");


    }
    else if(iNumber < 2)
    {
        printf("Not enough numbers!!!\n");


    }
    else if(iTotal < 9 && iTotal > 15)
    {
        printf("Not enough characters!!!\n");


    }
    printf("\n\n\n Your new password is verified " + password);


    printf("\n\n\n");
    system("pause");



}//end validatePass method

int countLetters(char * Password,int * Upper,int * Lower,int * Symbol,int * Number)
{
    int iTotal = 0,iC,tU = 0,tL = 0,tS = 0,tN = 0;


    //strlen- function that returns length
    for (iC = 0;iC < strlen(Password);iC++)
    {

        printf("%d",Password[iC]);
        //uppercase letters are in the range 65 - 90
        //lowercase letters are in the range 97 - 122

        //check upper case

        if((Password[iC] < 64) && (Password[iC] < 91))
        {
            tU++;
            iTotal++;

        }
        else if((Password[iC] > 96) && (Password[iC] < 123))
        {
            tL++;
            iTotal++;

        }
        else if((Password[iC] > 32) && (Password[iC] < 48))
        {
            tS++;
            iTotal++;

        }
        else if((Password[iC] > 47) && (Password[iC] < 58))
        {
            tN++;
            iTotal++;

        }

        *Upper = tU;/*set value at memory address = tU,passing by reference saves memory used.*/
        *Lower = tL;
        *Symbol = tS;
        *Number = tN;

    }//end for statement


    return (iTotal);
}//end of countLetters
4

1 回答 1

0

感谢您的帮助。我发现这是我使用 vs2012 创建的项目并转移到具有 v100 工具集的 vs2010 的问题?所以只需复制代码并在 vs2010 中创建一个新的 cpp 项目。

于 2012-11-20T14:40:39.890 回答