Be more specific as to what's wrong with them. And please use [code] and [/code] tags when posting code.
Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
In the second program you should really use islower() macro to check if the character is lower-case. Then use toupper() to convert from lower-case to upper-case, like this:
if( islower(str[i]))
str[i] = toupper(str[i]);
Otherwise, that program works ok for me. :)
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>I'm stumped again, is it my compiler?
Not your compiler -- its your code. Post your code because I can't see your computer's screen from where I am sitting.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>if ( islower(str[i])) >= 'a' && str[i] <= 'z') // If lowercase letter
wrong syntax. Should be this:
#include <ctype.h> // add this line somewhere after stdafx.h
for (unsigned int i = 0; i < strlen(str); i += 2)
{
if ( islower(str[i])) // If lowercase letter
str[i] = toupper(str[i]); // change to uppercase
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
@Ancient Dragon: Shouldn't it be cctype since we're in C++?
As for the code itself, it works fine for me. One thing you may want to try is removing the #include "stdafx.h" line. Or post the contents of stdafx.h if you really want a precompiled header.
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
> It says to add #include "stdafx.h" when i do that i get this error.
Lemme guess, you added this to stdafx.h as well.
"Hello, recursive file inclusion, WTF happened to all my disk space"
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953