I am trying to make a program which declares an array(string) which will gain its size and value during the run time , user will input them. This is a code , but it fails giving error: initializer failed to determine size of text.
string txt;
int x;
cout << "Enter the text\n";
cin >> txt;
char text[] = txt;
x = sizeof(text[]);
cout << x;
return 0;
This is another one, it gives error: storage size of text isn`t known.
char text[];
int x;
cout << "Enter the text\n";
cin >> text;
x = sizeof(text[]);
cout << x;
return 0;