转换C风格的字符串? [英] Convert a C-style string?

查看:79
本文介绍了转换C风格的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有明天到期的任务,我完全不知道这意味着什么,这是超级难的我觉得他们只是要求随机sh * t甚至没有在模块及其周末解释,所以我甚至不能告诉我的教授问他有人可以解释一下这个任务到底是什么意思吗?

第3部分:写一个函数调用To1337Speak()。将c风格的字符串转换为1337说话。寻找终止字符以找到字符串的结尾。



转换表:



a 4 < br $>

$ b $ 3 $



t 7



i!



l 1



o 0



g 9



s 5



我尝试过:



说实话,我还没有做过任何我研究过的c风格转换成什么但没有出现复制并粘贴在谷歌下的任务问题也没有出现

I have an assignment that is due tomorrow that I absolutely have no clue what it means at all ugh this is super hard I feel like they just ask for random sh*t that didn't even get explained in the module and its the weekend so I can't even msg my professor to ask him can someone explain what exactly this assignment means?
Part 3: Write a function called To1337Speak(). Convert a c-style string into 1337 speak. Look for the terminating character to find the end of the string.

Conversion table:

a 4

e 3

t 7

i !

l 1

o 0

g 9

s 5

What I have tried:

to be honest, I haven't done anything I've researched c style convert into but nothing came up copied and pasted the assignment question under google as well and nothing came up either

推荐答案

不要发誓。不要只是它不在笔记中。

阅读问题并思考它 - 如果你做他们想要你做的事情就很明显了。

他们希望你读一个C风格的字符串(即一个 char 的序列,它由一个空字符'\0'终止)并将一些字符转换为l337说话。

所以你好变成了h3110等等。

所有你需要做的就是读取字符串,循环遍历每个字符并将其替换为问题中的列表,当您到达null时停止。然后打印出来。

简单!



所以试一试 - 它并不像你想象的那么复杂。
Don't swear. Don't just go "it's not in the notes".
Read the question and think about it - it's pretty obvious if you do what they want you to do.
They want you to read a C-style string (i.e. a sequence of char values which is terminated by a null character '\0') and convert some of the characters to l337 speak.
So "hello" becomes "h3110" and so forth.
All you need to do is read the string in, loop through each character and replace it from the list in the question, stopping when you reach the null. Then print it.
Simple!

So give it a try - it's not as complicated as you think.


这篇关于转换C风格的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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