我在引用主函数中的数组的函数中使用指向数组的指针。我完全忘记了指针。我正在努力:
int main(void){
int length;
char punct;
string password;
cout << "Enter length of passwords: " << endl;
cin >> length;
char array[length];
//run random password generator here
password = generator(*array);
cout << "Here is your password: " << endl;
return 0;
}
char* generator(char* array){
int counter = 0;
int random;
while(counter <= 8){
random = rand() % 200 + 32;
if(random >= 32 && random != 95 && random != 127)
char
}
return result;
}
我遇到了错误,但不能完全说明我在这里搞砸了什么。
He are the errors (sorry for not including them in the initial post):
password.cpp:7:14: error: two or more data types in declaration of ‘main’
password.cpp: In function ‘char* generator(char*)’:
password.cpp:31:3: error: expected unqualified-id before ‘}’ token
password.cpp:32:10: error: ‘result’ was not declared in this scope
谢谢你的帮助。