帮助修剪其返回字符 MIPS 的字符串输入
我正在用 MIPS 编写一个游戏,并输入一个玩家的名字。当我尝试打印类似以下内容时:
li $v0, 4
la $a0, playerName
syscall
li $v0, 4
la $a0, strEnd #strEnd = ("'s Hand: ")
syscall
所以我希望它显示:
"playerName's Hand: "
所有内容都不会出现在同一行上。相反,我得到:
"playerName
's Hand: "
我的问题是如何从我输入的名称中删除换行符?谢谢
I'm writing a game in MIPS and I take in a player's name. When I try to print something like:
li $v0, 4
la $a0, playerName
syscall
li $v0, 4
la $a0, strEnd #strEnd = ("'s Hand: ")
syscall
So I want it to display:
"playerName's Hand: "
Everything doesn't appear on the same line. I instead get:
"playerName
's Hand: "
My question is how can I strip the new line character from the name I took in? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除换行符:)
Removes the newLine character :)
遍历包含玩家姓名的字符串,直到到达空字符。存储该位置。然后在 pos-1 处放置一个空字符。 (我认为你也必须把它放在 pos-2 处,因为换行符有时是 2 个单独的字符。)
Go through the string containing the player name, until you reach the null character. Store that position. Then place a null character at pos-1. (I think you'll have to put it at pos-2 as well, since a newline is sometimes 2 separate characters.)