473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Is the first character in a string a letter?

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
Jan 31 '07 #1
12 1625

" Frank" <fr***@a-znet.comwrote in message
news:OV****************@TK2MSFTNGP05.phx.gbl...
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
Jan 31 '07 #2
The only thing wrong with it is that I couldn't find it

thanks

"Brian Muth" <bm***@mvps.orgwrote in message
news:eN**************@TK2MSFTNGP05.phx.gbl...
>
" Frank" <fr***@a-znet.comwrote in message
news:OV****************@TK2MSFTNGP05.phx.gbl...
>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

Jan 31 '07 #3
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
"Brian Muth" <bm***@mvps.orgwrote in message
news:eN**************@TK2MSFTNGP05.phx.gbl...
>
" Frank" <fr***@a-znet.comwrote in message
news:OV****************@TK2MSFTNGP05.phx.gbl...
>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

Jan 31 '07 #4
I found something to try
" Frank" <fr***@a-znet.comwrote in message
news:OX**************@TK2MSFTNGP04.phx.gbl...
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
"Brian Muth" <bm***@mvps.orgwrote in message
news:eN**************@TK2MSFTNGP05.phx.gbl...
>>
" Frank" <fr***@a-znet.comwrote in message
news:OV****************@TK2MSFTNGP05.phx.gbl...
>>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


Jan 31 '07 #5
Frank wrote:
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
Jan 31 '07 #6
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
"David Wilkinson" <no******@effisols.comwrote in message
news:ew**************@TK2MSFTNGP05.phx.gbl...
Frank wrote:
>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

Jan 31 '07 #7

" Frank" <fr***@a-znet.comwrote in message
news:OO**************@TK2MSFTNGP04.phx.gbl...
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/lib...z8(VS.80).aspx

Brian
Jan 31 '07 #8

" Frank" <fr***@a-znet.comwrote in message
news:er*************@TK2MSFTNGP02.phx.gbl...
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
char *p = szTmpStr2;
while (iswspace(*p)) p++;

Jan 31 '07 #9
I'm constantly on it
Knowing the correct thing to search for is the trick to not getting 10
million hits

"Brian Muth" <bm***@mvps.orgwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>
" Frank" <fr***@a-znet.comwrote in message
news:OO**************@TK2MSFTNGP04.phx.gbl...
>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/lib...z8(VS.80).aspx

Brian

Jan 31 '07 #10
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]))


"Brian Muth" <bm***@mvps.orgwrote in message
news:ec****************@TK2MSFTNGP02.phx.gbl...
>
" Frank" <fr***@a-znet.comwrote in message
news:er*************@TK2MSFTNGP02.phx.gbl...
>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

char *p = szTmpStr2;
while (iswspace(*p)) p++;

Jan 31 '07 #11
In article <eH**************@TK2MSFTNGP02.phx.gbl>,
Frank <fr***@a-znet.comwrote:
>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
Jan 31 '07 #12
Thanks
"Nathan Mates" <na****@visi.comwrote in message
news:12*************@corp.supernews.com...
In article <eH**************@TK2MSFTNGP02.phx.gbl>,
Frank <fr***@a-znet.comwrote:
>>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

Jan 31 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: frizzle | last post by:
Hi there! I have (for sofar) a small problem: I have a site, with mySQL-backend, and an online admin system. The site is in three languages: 1 of them is German. My poblem concerns the 'ß'...
3
by: Nacho | last post by:
i need to convert the first letter of a veriable to uppercase (the veriable is loaded and the applied LCase() ) thanks -- Nacho
10
by: Sergio del Amo | last post by:
Hi, I am trying to create a web site to work in Opera 7.2, Explorer 6.0 and Mozilla 1.4. I have the code: var imgs= document.getElementsByTagName("img"); alert(imgs.id); The id of imgs is...
12
by: Alan J. Flavell | last post by:
OK, today's email brought a comment from a reader, pointing out something that I'd long since noticed myself but hadn't done anything about it. On my pages, I've got a first-letter style on...
2
by: coolvixs | last post by:
hi, i have some data in mysql in a column like this: 6.1.01 Financial Regulations 3.32.02 Academic Counseling what iam selecting is select by letter A, B, C...Z. so my first char in the...
15
by: wizardyhnr | last post by:
i want to try ANSI C99's unicode fuctions. so i write a test program. the function is simple, but i cannot compile it with dev c++ 4.9.9.2 under windows xp sp2, since the compiler always think that...
44
by: Kulgan | last post by:
Hi I am struggling to find definitive information on how IE 5.5, 6 and 7 handle character input (I am happy with the display of text). I have two main questions: 1. Does IE automaticall...
9
by: sovht | last post by:
System: Intel, Windows XP Pro, SP2 IDE: VC++ 6.0 Problem: *Very* simple program to create a MessageBox only ever displays the first character of the given string. I checked the spec for the...
40
by: Tameem | last post by:
hi my name is tameem. i am a new c programmer. in a c program i want to give input ""tameem"" and the output will be ""xdphhp"" in a short: the character ""a"" will be replaced by ""d"" i can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.