C ++

  Smithick 12:44 29 May 03

Dear... everyone

I have Microsofts Visual C++ 6.0.
I also have a big error in it.

I use the 'toupper' statements to compare two strings yet if I leave out the header file '#include ctype>'. All the lines with 'toupper'() display error C2664. If I add in the heading line, that line itself becomes the only error!
Am I spelling the heading statement wrong. Though this would cuase a degree of embarassment it would also be easily corrected.

  The Ghost of Inept Pig 12:51 29 May 03

Shouldn't that be:

#include <ctype.h>

  Smithick 13:14 29 May 03

I do believe both


work Ghost. yet for the first line an extra line is needed 'using namespace.std;'. It allows the computer to recognise differnet strings that have the same name(or something).

I actually think I have spelt the <ctype> wrong as it could be cctype. Anyway it is the header file to allow typecasting of any strings in the program.

  davidg_richmond 14:44 29 May 03

Smithick - What is the line of code involving toupper? I think this is where the problem lies and not the header. Are you converting a string or a single character? It will only work on a single char.

#include <ctype> only works if you have Visual C++ set to take it (its somewhere in the Preferences).

  Smithick 14:55 29 May 03

The line involving the 'toupper' statement is
'infile.getline(toupper(cdtitle), 40, '/');'

I'm reading data from a file and want the character array 'cdtitle' to be changed to uppercase letters so I can compare them to another character array.

Thanks for any help.

  davidg_richmond 15:14 29 May 03

The problem lies in using a character array in full with toupper, as it will only take single characters.

You would be better creating a new procedure, such as 'uppercase(char* cdtitle)'


int i=0;
while (str[i] != '\0')

when you return the character array should be in upper case. you may need to tweak my coding though, it's been a year since i've used C++ frequently.

  Smithick 11:29 02 Jun 03

Indeed the context behind the code does work. I have no errors yet still it is not good enough.

Thanks for your help folks.

This thread is now locked and can not be replied to.

Microsoft Surface Studio PC release date, pricing, design, features and spec: Microsoft showcases…

1995-2015: How technology has changed the world in 20 years

This amazing app turns your iPad Pro into a Cintiq

Apple Q4 2016 financial results | Apple earnings report: iPhone, iPad and Mac sales down, profits d6…