#include<iostream>
using namespace std;
void main()
{
char fname[11];
int x = 0;
cout << "Please enter the name: ";
cin >> fname;
while (fname[x] != '\0')
{
int i=int(fname[x]);
if (i>=97)
cout << fname[x];
x++;
}
else
cout << "Invalid characters";
system("pause");
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用上面的代码验证char输入.但是做不到.
这些代码有什么问题?