Dynamic Arrays

I have this working but is there a way that I can create the dynamic arary with the length of the chars that are input?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <cctype>

/* Write a program that prompts the user to input a string and outputs
the string in uppercase letters. (Use a character array to store the string)  Use only dynamic arrays.*/

using namespace std;

int main()
{
	int xxx;
	char *name;
	name = new char [20];
	cout<<"Enter a name: "<<endl;
	cin.get(name,20);
	for(int i = 0; i < 20; i++)
		cout<<static_cast<char>(toupper(name[i]));
	cout<<endl;
	cin>>xxx;  //read output
	return 0;
}
yep... check for the consoles input buffer events...
Last edited on
Topic archived. No new replies allowed.