Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to convert uppercase letters to lowercase in C language

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

The editor of this article introduces in detail "how to convert uppercase letters to lowercase in c language". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to convert uppercase letters into lowercase in c language" can help you solve your doubts. Let's follow the editor's train of thought to learn new knowledge.

#! / bin/bash

# name: upper_to_lower.sh

# the function is trun uper to lower

# like ABCd to abcd

Haveuppernumber ()

{

# test if the string have upper number

Str= "$(echo $1 | tr'[: upper:]'[: lower:]')"

If ["$str"! = $1]; then # get some problem

Echo "[# have upper number,and i well trun them to lower:#]"

Return 1 # have upper number

Else

Return 0 # no upper number

Fi

}

If [$#-ne 1]; then

Echo "Usage: $0" > & 2

Exit 1

Fi

If! Haveuppernumber $1; then # when if is 0 it run?

# if [0]; then # in shell true return 0, false return 1

Echo $1 | tr'[: upper:]'[: lower:]'# it can turn the UPPER number to lower

# echo $1 | tr'[: lower:]'[: upper:]'# it can turn the lower number to UPPER

Else

Echo "[# no upper number:#]"

Echo $1

Fi

Exit 0

Function description: when entering ". / upper_to_lower.sh AaBbCcdd" will first determine whether the input format is correct, and then determine whether there are uppercase letters in the string if there is a display of "[# have upper number,and i well trun them to lower:#]" and the string converted to lowercase letters; if there are no uppercase letters display "[# no upper number:#]" and lowercase string.

Then try to achieve the same function in C language, as follows:

The code is as follows:

# include

# include

Int haveuppernumber (char * p)

{

Char*q=p

For (; * QQ stories'\ 0percent investors +)

{

If (* Q > = 'Asians, girls, boys, girls, boys, girls, girls, boys, girls,

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report