c中的null char [英] null char in c

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

问题描述


我有这段代码,为什么显示的结果为false?

展开 | 选择 | Wrap | 行号

推荐答案

将其更改为:

Change that to:

展开 | 选择 | 换行 | 行号


或者更好的是,您可以使用此表单:

char my_string [] ="编译器将确定此字符串的大小" ;;


这样,只要您不打算在运行时更改字符串,就不必担心知道实际的字符串大小。如果你把它变成一个const char,那就更好了。为了增加安全性。
Or better yet, you can just use this form:
char my_string[] = "the compiler will determine this string''s size";

This way, you will not have to worry about knowing the actual string size as long as you don''t plan on changing the string during runtime. Even better if you make it a "const char" for added safety.


thanx,但为什么当我为两个数组使用6时它不起作用?我的意思是它们都不会以null char结束,所以为什么不是'他们等于?
thanx,but why it doesn''t work when i use 6 for both arrays?i mean they both don''t end with the null char so why aren''t they equal??


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

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