I’m using a pointer to an array in a function that reference a array in the main function. I’ve completely forgotten about pointers. I’m trying:
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;
}
I’m getting errors but can’t quite put a finger on what I’m screwing up here.
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
thanks for any help.
First of all,i can tell you many reasons for the errors If you are using the exact program to compile,
lengthdoes not has an initializationThe
signatureof the functionotherFunctionvaries between where it is called and its definition*array[i]does not make any sense in the definition ofotherFunctionsincearray[i]itself is a dereference operationI think this is what you are expecting
O/P: