Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / January 2007

Tip: Looking for answers? Try searching our database.

Is the first character in a string a letter?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank - 31 Jan 2007 16:42 GMT
There must be an easier way then what I'm doing to determine if the first
character in a string is a valid letter.

My code is getting to big. There must be a better way.

Thanks in advance
Brian Muth - 31 Jan 2007 16:56 GMT
> There must be an easier way then what I'm doing to determine if the first
> character in a string is a valid letter.
>
> My code is getting to big. There must be a better way.

Anything wrong with isalpha(s[0]) ?

Brian
Frank - 31 Jan 2007 17:02 GMT
The only thing wrong with it is that I couldn't find it

thanks

>> There must be an easier way then what I'm doing to determine if the first
>> character in a string is a valid letter.
[quoted text clipped - 4 lines]
>
> Brian
Brian Muth - 31 Jan 2007 17:41 GMT
> The only thing wrong with it is that I couldn't find it
>
> thanks

Couldn't find it? Have you heard of Google by any chance?

http://msdn2.microsoft.com/en-us/library/xt82b8z8(VS.80).aspx

Brian
Frank - 31 Jan 2007 18:43 GMT
I'm constantly on it
Knowing the correct thing to search for is the trick to not getting 10
million hits

>> The only thing wrong with it is that I couldn't find it
>>
[quoted text clipped - 5 lines]
>
> Brian
Frank - 31 Jan 2007 17:14 GMT
While I was at it I should have asked you about trimming a string of leading
white space.

Is there a easy way?

I've been searching the doc and the internet but can't find anything.

Thanks again

>> There must be an easier way then what I'm doing to determine if the first
>> character in a string is a valid letter.
[quoted text clipped - 4 lines]
>
> Brian
Frank - 31 Jan 2007 17:21 GMT
I found something to try

> While I was at it I should have asked you about trimming a string of
> leading white space.
[quoted text clipped - 13 lines]
>>
>> Brian
David Wilkinson - 31 Jan 2007 17:25 GMT
> While I was at it I should have asked you about trimming a string of leading
> white space.
>
> Is there a easy way?
>
> I've been searching the doc and the internet but can't find anything.

Frank:

If you are using CString then there is TrimLeft().

David Wilkinson
Frank - 31 Jan 2007 17:40 GMT
I'm doing plain C
Can you see what is wrong with the while statement
ComboBox_GetText(GetDlgItem( hDlg, IDC_N_USERNAME), szTmpStr,
SIZE_OF_USER_NAME);

strcpy_s(szTmpStr2,72,szTmpStr);

strcat_s(szTmpStr2,72, "5"); //Make sure the strip code that follows leaves
something

while (iswspace(*szTmpStr2)) szTmpStr2++; //Error 1 error C2105: '++' needs
l-value

if( !isalpha(szTmpStr2[0])) //check the first character

Thanks for the reply

>> While I was at it I should have asked you about trimming a string of
>> leading white space.
[quoted text clipped - 8 lines]
>
> David Wilkinson
Brian Muth - 31 Jan 2007 17:45 GMT
> I'm doing plain C
> Can you see what is wrong with the while statement
[quoted text clipped - 8 lines]
> while (iswspace(*szTmpStr2)) szTmpStr2++; //Error 1 error C2105: '++'
> needs l-value

char *p = szTmpStr2;
while (iswspace(*p)) p++;
Frank - 31 Jan 2007 18:59 GMT
I should have given you one more line of code

ComboBox_GetText(GetDlgItem( hDlg, IDC_N_USERNAME), szTmpStr,
SIZE_OF_USER_NAME);

strcpy_s(szTmpStr2,72,szTmpStr);

strcat_s(szTmpStr2,72, "5"); //Make sure the strip code that follows leaves
something

while (isspace(*szTmpStr2)) szTmpStr2++; //Error 1 error C2105: '++' needs
l-value

if( !isalpha(szTmpStr2[0]))

>> I'm doing plain C
>> Can you see what is wrong with the while statement
[quoted text clipped - 11 lines]
> char *p = szTmpStr2;
> while (iswspace(*p)) p++;
Nathan Mates - 31 Jan 2007 19:16 GMT
>strcpy_s(szTmpStr2,72,szTmpStr);
>strcat_s(szTmpStr2,72, "5"); //Make sure the strip code that follows leaves
>something
>while (isspace(*szTmpStr2)) szTmpStr2++; //Error 1 error C2105: '++' needs
>l-value

  Make a pointer, then ++ it. For example:

  char* pStart = &szTempStr2[0];
  while(isSpace(*pStart)) ++pStart;

  At the end, pStart is a pointer to some memory (WITHIN szTempStr2)
that has the string minus any leading spaces. Copy that off to another
buffer if you want.

Nathan Mates
--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/ 
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein
Frank - 31 Jan 2007 19:27 GMT
Thanks
>>strcpy_s(szTmpStr2,72,szTmpStr);
>>strcat_s(szTmpStr2,72, "5"); //Make sure the strip code that follows
[quoted text clipped - 19 lines]
> # think. What are the facts, and to how many decimal places?" -R.A.
> Heinlein

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.