转换arrayof字符字符串 [英] convert arrayof characters to string
问题描述
我用C语言编写code。
-
烧焦一个[] = {P,R,A,D,E,E,P}
结果
我想补充0 /
末使它的字符串。结果
或者是有使它比在结束了吗? 添加另外null字符串的方法 -
的char * A =普拉迪普;
结果
通过在末尾添加空将它转换为字符串
您不能更改数组的大小 A
,所以你不能一个空终止添加到它。你可以改变声明:
的char a [] =普拉迪普;
这将暗示加空终止符。或者:
烧焦一个[] = {'P','R','A','D','E','E','P',0};
但字符串是简单和清晰。大多数,如果不是所有的C字符串的库函数需要一个空值终止字符串。
I am writing code in c language.
char a[]={p,r,a,d,e,e,p}
I want to add'0/'
at the end to make it string.
Or is there any method to make it string other than adding null at the end?char *a=pradeep;
Convert this to string by adding null at the end
You can't change the size of the array a
so you cannot add a null terminator to it. You could change the declaration to:
char a[] = "pradeep";
which will implicitly add the null terminator. Or:
char a[] = { 'p', 'r', 'a', 'd', 'e', 'e', 'p', 0 };
but the string literal is simpler and clearer. Most, if not all, of the C string library functions require a null terminated string.
这篇关于转换arrayof字符字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!