how can i verify and captalise my first character of string


 
Thread Tools Search this Thread
Top Forums Programming how can i verify and captalise my first character of string
# 1  
Old 10-01-2008
how can i verify and captalise my first character of string

Hi ,

With some modification in below , I would like to verify my first char of string weather it is capital letter or not, if it is not than i would like to capitalize it some body help me in modifying codethis code:


text = XmTextGetString(crn1_text_modname);
if ( ( text[0] == ' ' || text[0] == '\0'))
{
show_error("Model Name is a Required Field");
return;
}
strcpy( component_buff->device_model, text );
strncpy(HARDWARE_APL_ARCHIVE->model_no, text, strlen(text)+1);
XtFree(text);
# 2  
Old 10-01-2008
You probably need the islower(3) and toupper(3) functions in ctype.h.
e.g.
Code:
if( islower(text[0]) ) text[0] = toupper(text[0]);

remembering that what counts as lower-case depends on the current locale.

As an aside, make sure that you free text before the early return.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed searches a character string for a specified delimiter character, and returns a leading or traili

Hi, Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank. Text file : "1"|"ExternalClassDEA519CF5"|"Art1" "2"|"ExternalClass563EA516C"|"Art3" "3"|"ExternalClass305ED16B8"|"Art9" ... ... ... (2 Replies)
Discussion started by: fspalero
2 Replies

2. Shell Programming and Scripting

replace character from string

I have a string ----- i want to replace the 3rd '-' with a character How can i do that Basically im trying to do hangman I have added the '-----' string to a file called hash and i have the character in a variable called $input also i have the character location(index) in this variable... (12 Replies)
Discussion started by: omaral
12 Replies

3. UNIX for Dummies Questions & Answers

Verify if substring is found in string

Hi, I'm new to HP-UNIX programming(previously using C++). I am looking for an IF statement which would return TRUE if a substring is found in a string. For example, if 'header' is found in 'header_cp', the IF statement will result to true. Would appreciate any help... (1 Reply)
Discussion started by: miashaykoh
1 Replies

4. Shell Programming and Scripting

Korn: How to loop through a string character by character

If I have a string defined as: MyString=abcde echo $MyString How can I loop through it character by character? I haven't been able to find a way to index the string so that I loop through it. shew01 (10 Replies)
Discussion started by: shew01
10 Replies

5. UNIX for Dummies Questions & Answers

access each character in a string

Hi All, I'm writing a script where one of the parameter is a string like: 0011001100 Then I want to do a while loop, according to the value of each character. Could tell how I can access the value of each character in the string? Thank you, Gino (6 Replies)
Discussion started by: f_o_555
6 Replies

6. Shell Programming and Scripting

how to check string of character

how can i check whether variable contains only character from a-z or A-Z....if my variable contains any alpha numeric, numeric or any character with some special one i.e. *%&@! etcetera etcetera....then it should show me please enter only characters...... Let my variable var1="abc77}|" then... (9 Replies)
Discussion started by: manas_ranjan
9 Replies

7. Shell Programming and Scripting

how to display only last character of a string?

hi all, if i do an: "echo $string |" what should be after the pipe to display ONLY the last char of the output? tia, DN2 (9 Replies)
Discussion started by: DukeNuke2
9 Replies

8. Programming

converting character string to hex string

HI Hi I have a character string which contains some special characters and I need it to display as a hex string. For example, the sample i/p string: ×¥ïA Å gïÛý and the o/p should be : D7A5EF4100C5010067EFDBFD Any pointers or sample code pls. (5 Replies)
Discussion started by: axes
5 Replies

9. Shell Programming and Scripting

Testing the last character in a string

Hi In the shell scripted I'm trying to write! I would like to test the last character in a string. The string is a path/directory and I want to see if the last character is a '/'. The string (path/directory) is inputted by a user. If the '/' character isn't present then I want to be able to... (11 Replies)
Discussion started by: dbrundrett
11 Replies
Login or Register to Ask a Question