小写到大写 [英] lower case to upper case

查看:131
本文介绍了小写到大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

char * line =" abcd";

如何将线条转换为大写并打印?

printf的任何选项都可以执行此操作?

Thanx

char* line = "abcd";
How to convert the line to upper case and print?
Any option for printf to do this?
Thanx

推荐答案




Janice写道:


Janice wrote:
char * line =" abcd";
如何将线条转换为大写并打印?
printf的任何选项都可以这样做吗?
Thanx
char* line = "abcd";
How to convert the line to upper case and print?
Any option for printf to do this?
Thanx




不确定''C'中是否有专属功能

但是你可以这样做:


- 从输入数组/字符串中逐个获取每个字符。

- 使用''islower''或''isupper''检查字符是否为低/高>
函数

- 如果字符为大写,则添加32以获得其小写

等价或

- 如果字符是小写减去32得到它的大写。

- 存储或打印转换后的字符。

你可能也希望对输入数组进行错误检查,如果它们是b / b
有效的字母表!


- Ravi



Not sure if there is a exclusive function in ''C'' to do it
but tivially you could do:

- Get each character one by one from the input array/string.
- Check whether the character is lower/upper using ''islower''or ''isupper''
functions
- If character is upper case, then Add 32 to get its lower case
equivalent or
- If character is lower case Subtract 32 to get its upper case.
- Store or print the converted characters.

You might want to do error checking on the input array too if they are
valid alphabets !

- Ravi


Ravi Uday< ra ****** @ gmail.com>潦草地写道:
Ravi Uday <ra******@gmail.com> scribbled the following:
Janice写道:
char * line =" abcd" ;;
如何将线转换为大写并打印?
printf的任何选项都可以这样做吗?
Thanx
char* line = "abcd";
How to convert the line to upper case and print?
Any option for printf to do this?
Thanx


不确定C中是否有独占功能来做


有。看看toupper()。

,但是你可以做到:
- 从输入数组/字符串中逐个获取每个字符。
- 检查字符是否较低/鞋面使用''islower''or''isupper''
函数
- 如果字符是大写字母,那么添加32以获得其小写
等效或
- 如果字符是小写字母减去32得到它的大写字母。
- 存储或打印转换后的字符。

Not sure if there is a exclusive function in ''C'' to do it
There is. Check out toupper().
but tivially you could do: - Get each character one by one from the input array/string.
- Check whether the character is lower/upper using ''islower''or ''isupper''
functions
- If character is upper case, then Add 32 to get its lower case
equivalent or
- If character is lower case Subtract 32 to get its upper case.
- Store or print the converted characters.




Bzzzt。没有人告诉你,你使用的是ASCII,ISO-8859-1或任何其他的

字符集,其中大小写字母相隔32个字节。


-

/ - Joona Palaste(pa*****@cc.helsinki.fi)-------------芬兰-------- \\ \\

\ --------------------------------------- -----------------规则! -------- /

更强,没有。黑暗面是更诱人,狡猾,更嘎吱嘎吱的。

- Mika P. Nieminen



Bzzzt. No one told you you were using ASCII, ISO-8859-1 or any other
charset where upper and lower case are 32 bytes apart.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"Stronger, no. More seductive, cunning, crunchier the Dark Side is."
- Mika P. Nieminen


Ravi Uday< ra **** **@gmail.com>写道:
Ravi Uday <ra******@gmail.com> wrote:


Janice写道:


Janice wrote:
char * line =" abcd" ;;
如何将线转换为大写并打印?
printf的任何选项都可以吗?
Thanx
char* line = "abcd";
How to convert the line to upper case and print?
Any option for printf to do this?
Thanx



不确定C中是否有独占功能要做到这一点
但是你可以做到这一点:

- 从输入数组/字符串中逐个获取每个字符。
- 使用'检查字符是否为低/高'islower''or''isupper''
函数
- 如果字符为大写,则添加32以获得其小写
等效或
- 如果字符为小写减去32得到它的大写。
- 存储或打印转换后的字符。

如果它们是有效的字母表,你可能也想对输入数组进行错误检查!



Not sure if there is a exclusive function in ''C'' to do it
but tivially you could do:

- Get each character one by one from the input array/string.
- Check whether the character is lower/upper using ''islower''or ''isupper''
functions
- If character is upper case, then Add 32 to get its lower case
equivalent or
- If character is lower case Subtract 32 to get its upper case.
- Store or print the converted characters.

You might want to do error checking on the input array too if they are
valid alphabets !



听说过tolower / toupper吗?


您的建议不是便携式的,只会出现问题在一台机器上

,其中所有小写字符都由一个大于相应的大写字符表示的值表示32

。由于这个

实际上并不是这样,标准为您提供了需要您的实现支持的功能

,这使得
$ b $的使用b便携式。


-

Z(Zo**********@daimlerchrysler.com)

LISP值得学习深刻的启蒙经验

当你终于得到它时你将拥有;这段经历会让你在剩下的日子里成为更好的程序员。 - Eric S. Raymond


ever heard of tolower/toupper?

Your suggestions are not portable and will only function on a machine
where all lower case characters are represented by a value that is by 32
bigger than the according upper case characters representation. As this
need not actually be the case the standard provides you with functions
that need to be supported by your implementations, which makes usage of
them portable.

--
Z (Zo**********@daimlerchrysler.com)
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond


这篇关于小写到大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆