更改代码语法

编程入门 行业动态 更新时间:2024-10-26 14:34:07
本文介绍了更改代码语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要帮助才能从??修改此代码.标准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? -Saurabh

I 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;

更多推荐

更改代码语法

本文发布于:2023-07-30 00:20:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1244929.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语法   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!