Here is a different, more standard version:
Code:
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
char *array = new char[20];
cout << "Enter a string: ";
cin.getline(array, 20);
cout << "You have entered " << array << endl;
cout << "The size of your array is " << strlen(array) << " characters" << endl;
for(int x = 0; x < 20; x += 2)
array[x] = toupper(array[x]);
cout << "You have entered " << array << endl;
delete [] array;
return 0;
}
You should/could use the standard toupper() function and the strlen() makes more sense to use in this situation. Also you forgot to deallocate the memory you allocated.