< CR>成为字符串 [英] <CR> into string

查看:50
本文介绍了< CR>成为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想插入< CR>在某个

位置的字符串中是0x0D,我可以使用任何字符串函数吗?

谢谢。

Hi,

I would like to insert <CR> which is 0x0D into a string at certain
position, any string function that I can use ?
Thanks.

推荐答案



" Magix" <毫安*** @ asia.com>在消息中写道

news:41 ********** @ news.tm.net.my ...

"Magix" <ma***@asia.com> wrote in message
news:41**********@news.tm.net.my...


我想插入< CR>在某个
位置是一个字符串是0x0D,我可以使用任何字符串函数吗?
谢谢。
Hi,

I would like to insert <CR> which is 0x0D into a string at certain
position, any string function that I can use ?
Thanks.




没有必要用于在字符串中添加/插入字符的功能。


#include< stdio.h>

#include< string.h>


int main()

{


char arr [10] =" Hello";


/ *现在假设您需要在末尾添加0x0D * /


int i = strlen(arr); / *获取字符串的长度* /


arr [i] = 0x0d;

arr [i + 1] =''\ 0'';

返回0;

}


HTH,

-Ravi




There is no need for a function to add/insert a character to a string.

#include <stdio.h>
#include <string.h>

int main ()
{

char arr[10] = "Hello";

/*Now suppose you need to add 0x0D at the end*/

int i = strlen(arr);/* Get the length of the string */

arr[i] = 0x0d;
arr[i+1] = ''\0'';

return 0;
}

HTH,
-Ravi



Ravi Uday在02/08/04写道:
Ravi Uday wrote on 02/08/04 :
我想插入< CR>在某个
位置是0x0D到一个字符串,我可以使用任何字符串函数吗?
谢谢。
I would like to insert <CR> which is 0x0D into a string at certain
position, any string function that I can use ?
Thanks.



不需要添加/的函数将字符插入字符串。

#include< stdio.h>
#include< string.h>

int main()
{

char arr [10] =" Hello";

/ *现在假设您需要在末尾添加0x0D * /
int i = strlen(arr); / *获取字符串的长度* /

arr [i] = 0x0d;
arr [i + 1] =''\ 0 '';

返回0;
}



There is no need for a function to add/insert a character to a string.

#include <stdio.h>
#include <string.h>

int main ()
{

char arr[10] = "Hello";

/*Now suppose you need to add 0x0D at the end*/

int i = strlen(arr);/* Get the length of the string */

arr[i] = 0x0d;
arr[i+1] = ''\0'';

return 0;
}




如果你想在最后添加一个,你需要strcat()或者sprintf()。否

需要重新发明。


char arr [10] =" Hello";


strcat(arr," \r");



strcat(arr," \ xd");


但OP希望插入一个角色。这不是微不足道的。


-

Emmanuel

C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html


C是一个敏锐的工具



If you want to add a at the end, you want strcat() or sprintf(). No
need to reinvent the weel.

char arr[10] = "Hello";

strcat (arr, "\r");
or
strcat (arr, "\xd");

But the OP wanted to ''insert'' a character. And this is not trivial.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"


Magix在02/08/04写道:
Magix wrote on 02/08/04 :
我想插入< CR>在某个
位置的字符串是0x0D,我可以使用任何字符串函数吗?
I would like to insert <CR> which is 0x0D into a string at certain
position, any string function that I can use ?




没有标准函数。你可以写自己的,但要小心。不要溢出输出数组,并记住字符串

文字既不能写也不能调整大小。


你最好发布你的尝试。


-

Emmanuel

C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html


C是一个尖锐的工具



There is no standard function for that. You can write your own, but be
careful. Don''t overflow the output array, and bear in mind that string
literals can neither be written nor resized.

Do you best and post your attempts.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"


这篇关于&LT; CR&GT;成为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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