I want to create a program that takes each letter from a sentence that a user types and stores it into an array and print it. I used pointer to define the size of the array. However, when I try to print the array, the program prints numbers(most likely the memory location) instead of the characters in the array.
#include <conio.h>
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
int* a;
string user_input;
cout << "Please type your sentence\n";
getline(cin, user_input);
int lengOfStr = user_input.length();
a = newint[lengOfStr];
for (int i = 0; i < lengOfStr; i++)
{
a[i] = user_input[n];
cout << a[i]; // THIS line is the issue
}
_getch();
return 0;
}