I'm trying to declare a char* using dynamic memory allocation then initialize it with a string of characters, but I keep getting this error...
Error Message:
a value of type "const char *" cannot be used to initialize an entity of type "int *"
Code:
void main() {
char *alphabet = new char();
alphabet = "abcdefghijklmnopqrstuvwxyz";
cout << alphabet;
system("pause");
}
I understand that this
void main() {
char *alphabet = new char();
cin.getline(alphabet, 255);
cout << alphabet;
system("pause");
}
will work, but I don't understand why I can't initialize it without user input;