本文介绍了更改代码语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要帮助才能从??修改此代码.标准micosoft visual C ++的语法表示相同功能的语法!
int countNumChars(int pass[]); int countChars(char pass[]); bool isValidPassword(char *password); int main() { char pass[24]; // To store password cout << "password must have at least 6\n"; cout << "characters and one digit (1-9).\n"; cout << "Please enter a password: "; cin >> pass; while(!isValidPassword(pass)) { cout << "Please enter password: "; cin >> pass; } cout << "Thank you, that is a valid password.\n"; return 0; } bool hasNumChars(char pass[]) // definitions of digit of password characters. { int len = strlen(pass); for (int count = 0; count < len; count++) { if (pass[count] >=''1'' && pass[count] <= ''9'') { return true; } else; } return false; } bool isValidPassword(char *password) // password validator { int len = strlen(password); if (len<6) { cout >> "Password must be at least 6 characters.\n"; return false; } if(!hasNumChars(password)) { cout >> "Password must have at least one digit(1-9).\n"; return false; } return true; }解决方案
问题语法是什么? -Saurabh
我不知道你在说什么.在我看来,这就像标准的C ++.除非您使用非C ++包含,否则您不会显示出来.诸如string之类的C ++标头不是string.h,而只是string. iostream是相同的.
您的问题不清楚. 您的老师用" ??语法"到底是什么意思?!? 请他向您确切显示代码中包含此类问题的部分. 注意:您的代码只有在其前缀为的情况下才会编译 #include < iostream > #include < 字符串 > 使用 命名空间 std;
I need help to modify this code from a ?? syntax to standard micosoft visual C++ express syntax to do the same the same thing!
int countNumChars(int pass[]); int countChars(char pass[]); bool isValidPassword(char *password); int main() { char pass[24]; // To store password cout << "password must have at least 6\n"; cout << "characters and one digit (1-9).\n"; cout << "Please enter a password: "; cin >> pass; while(!isValidPassword(pass)) { cout << "Please enter password: "; cin >> pass; } cout << "Thank you, that is a valid password.\n"; return 0; } bool hasNumChars(char pass[]) // definitions of digit of password characters. { int len = strlen(pass); for (int count = 0; count < len; count++) { if (pass[count] >=''1'' && pass[count] <= ''9'') { return true; } else; } return false; } bool isValidPassword(char *password) // password validator { int len = strlen(password); if (len<6) { cout >> "Password must be at least 6 characters.\n"; return false; } if(!hasNumChars(password)) { cout >> "Password must have at least one digit(1-9).\n"; return false; } return true; } 解决方案 What is a question syntax? -SaurabhI have no idea what you''re talking about. This looks like standard C++ to me. Unless you use non C++ includes, but you don''t show that. C++ headers for things like string are not string.h, just string. iostream is the same.Your question is not clear. What exactly do your teacher mean with "?? syntax"?!? Ask him to show you exactly what is the part of your code with such a problem. Note: your code will not compile unless you prefix it with #include <iostream> #include <string> using namespace std;更多推荐
更改代码语法
发布评论