So I have a program I am working on that utilizes a dynamic array and then takes a series of lowercase letters and changes them to uppercase. I have this program so far but when I entered in the toupper to switch from lowercase to uppercase I keep getting errors. I do not know what I am doing wrong so any pointers would be appreciated. I am pretty positive that my code is pretty much done but I am just making a mistake somewhere. Thanks in advance for any help.

Code:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{

char* letter;
int numberOfLetter;

cout << "Please enter the number of letters "
<< "you would like to capitalize:" << endl;

Thanks I totally forgot about the <cctype>. I am getting a build error and it is telling me that I need a identifier before the ';' token but I am not understanding what it is wanting. I have been tinkering but I am just trying to get it to compile.

04-28-2010

tabstop

An identifier before which ; token? (Although usually it's the other way around, but still.)

04-28-2010

limburger

The error message is specific too char *letter2 = new;

04-28-2010

tabstop

new is a keyword: new what?

04-28-2010

limburger

It is supposed to be a pointer to "char* letter". After I had taken a look to that line of code I realized I do not need anything other than "char *letter2;". The program compiled but I ran it, entered in the letters to convert and it gave the line "The letters you entered were:" and then windows force shut it down.

04-28-2010

limburger

This is the code that force closes my program. It is weird that it compiles but then doesnt allow the program to finish properly.

Code:

#include <cstdlib>
#include <iostream>
#include <cctype>

using namespace std;

int main(int argc, char *argv[])
{

char* letter;
int numberOfLetter;

cout << "Please enter the number of letters "
<< "you would like to capitalize:" << endl;

You need some letters there -- if you just do char *letter2; then letter2 points to New Jersey and you don't want to go there. You can make it point to letter if you want, or you can do another new char[array].

04-28-2010

limburger

So I got it to finally run the whole program but now I am getting symbols instead of letters.

Code:

#include <cstdlib>
#include <iostream>
#include <cctype>

using namespace std;

int main(int argc, char *argv[])
{

char* letter;
char* letter2;
int numberOfLetter;

cout << "Please enter the number of letters "
<< "you would like to capitalize:" << endl;

"new char" is incredibly wrong. You need an array of chars. You also never assign anything to letter2[i] before calling toupper, meaning you are calling toupper on complete nonsense, rather than the string that was typed in.