Does anybody know what class function is for checking if a string has any letter in upper case?
string FirstName_LastName
any function return the idex of char[] that is upper case ? thank you
Does anybody know what class function is for checking if a string has any letter in upper case?
string FirstName_LastName
any function return the idex of char[] that is upper case ? thank you
You could examine the string character by character, using the isupper( ) function from library <cctype>. When you find one, return that index.
Or, make use of the string function find_first_of( ) as this sample shows
#include <iostream>
#include<string>
using namespace std;
int main()
{
string s = "heLlo, World";
int spot = -1;
spot = s.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
cout << spot << endl;
return 0;
}
The output should be 2, which is the zero based index of the first capital letter.
im pretty sure there is a C library that has all kinds of functions like that.
alternatively you can just look at an ascii key code table and fidle with the numbers.
its pretty simple A + 32 = a, B + 32 = b
ascii was designed that way.
A=65 iirc
just iterate through your cstring (i dunno if offset opperator [] works with string.) checking if anything is between 65 and 91.
D.R
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.