完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,伙计们,我应该用0来终止char数组来制作一个字符串,然后把它传递给LCD显示器,比如C或C编译器处理这个,然后用空值结束任何字符数组?
以上来自于百度翻译 以下为原文 Hi Guys . Should i terminate char array with 0 to make t a string and then pass it to LCD display for instance like Lcd_Out() or C compiler handle this and end any char array with null value ? |
|
相关推荐
16个回答
|
|
如果你有类似的东西,编译器会自动添加零终止符。同样适用于SaveTFF和String函数。
以上来自于百度翻译 以下为原文 If you have something like char HelloString[] = "Hello, World"; The compiler automatically adds the zero terminator. The same applies to sprintf and the string functions. |
|
|
|
字符串常数,由双引号包围的字符列表:“字符串”,将在运行时由编译器添加一个空(0)字节(并且字符串存储在ROM中)。如果在运行时创建字符串,则负责整个字符串的组成。如果使用编译器提供的字符串函数,则检查编译器文档,有些添加NULL,有些则不添加NULL。至少这是我的经验。
以上来自于百度翻译 以下为原文 String constants, a list of characters surrounded by double quotes : "a string", will have a null (0) byte added by the compiler at run time (and the string is stored in ROM). If you create a string during run time you are responsible for the entire makeup of the string. If you use string functions provided by the compiler then check the compiler documentation, some add the null and some do not. At least that is my experience. |
|
|
|
对于期望空终止字符串的任何函数,都需要空终止字符串。WestLCDOUT()是期望的吗?
以上来自于百度翻译 以下为原文 You Need Null terminate strings for any function that expects Null terminated strings. is that what Lcd_Out() expects? |
|
|
|
不…我的意思是这样
以上来自于百度翻译 以下为原文 no ...i mean like this char array[10]; for(i=0;i<10;i++0 { array='a'; } |
|
|
|
数组是用null自动结束的,还是应该把它添加到我的代码中去数组[11 ],并分配这个数组(10)=0的null;
以上来自于百度翻译 以下为原文 is array is ended automatically with null or i should add it in my code to be array[11] and assign the null like this array[10]=0;? |
|
|
|
诺伊斯。如果您希望字符数组能够容纳十个字符,并且能够将其传递给需要终止null的函数,那么您必须允许11个字符,并且自己添加null。再次读取杰克的POST第3。
以上来自于百度翻译 以下为原文 no Yes. If you want the character array to be able to hold ten characters, AND be able to pass it to functions that require a terminating NULL, then you must allow for 11 characters, and add the NULL yourself. Read Jack's post#3 again. |
|
|
|
您应该添加空字符,但不是在数组末尾,而是在字符串的最后一个字符之后。数组可能要比那个长得多,但是对于面向字符串的函数,终止null以外的内容并不重要。
以上来自于百度翻译 以下为原文 You should add the NULL character, but not at the end of the array, but after the last character of the string. The array may be much longer than that, but, for the string-oriented functions, it doesn't matter what is beyond the terminating NULL. |
|
|
|
存储在ROM中?那么,我能从ROM中恢复它之后的休息像PIC例如EEPROM读函数吗?
以上来自于百度翻译 以下为原文 Stored in rom ?so can i retrieve it again from rom after resting the pic for example like EEPROM read function do ? |
|
|
|
不,“存储在ROM中”有一个与软件运行无关的实现细节。这不是在运行时发生的事情。
以上来自于百度翻译 以下为原文 No, the "stored in ROM" bit an implementation detail that isn't relevant to what your software is doing. It's not something that is happening at run-time. |
|
|
|
不,“存储在ROM中”有一个与软件运行无关的实现细节。这不是在运行时发生的事情,我什么也不懂。
以上来自于百度翻译 以下为原文 No, the "stored in ROM" bit an implementation detail that isn't relevant to what your software is doing. It's not something that is happening at run-time. i understand nothing |
|
|
|
然后用4多个词来阐明你的问题。
以上来自于百度翻译 以下为原文 Then use more than 4 words to clarify your question. |
|
|
|
字符串常量被存储为程序代码的一部分(在Flash ROM中),并且可以在运行程序时被移动到RAM中,无论是通过编译器的代码还是由特定编写的代码来执行。字符串常量是)。在程序代码执行过程中,用字符填充(写入)的任何字符数组将不会有一个终止空字符,除非您这样做。
以上来自于百度翻译 以下为原文 String constants are stored as part of the program code (in the FLASH ROM) and MAY be moved to RAM during the running of your program, either by code from the compiler or by your specifically written code to do so. THe example you gave in post #5 IS NOT a string constant (see earlier post for what a string constant is). ANY character array that you fill (write to) with characters during program code execution will NOT have a terminating null character added UNLESS YOU DO IT. |
|
|
|
|
|
|
|
当你把一个指向字符串的指针交给一个基于字符串的函数时,空值的缺失就变得明显了。
以上来自于百度翻译 以下为原文 And the absence of that null will become apparent once you hand a pointer to that "string" to a string-based function.... |
|
|
|
是的,由双引号包围的字符(“一些字符”)。在XC8用户指南中有一个关于此的部分。基本上,如果您将字符串写入程序代码:“Hello World”,那么编译器将空字符放置在字符串中的末尾(当它在赋值语句中使用时)(等号的右手边(即:CHARAR数组[10 ] =)HEL。如果你写一个循环,就像你在POST 5中所做的那样,编译器不会添加空终止字符,你必须这样做。
以上来自于百度翻译 以下为原文 Yes, characters surrounded by double quotes ("some characters"). There is a section in the XC8 user guide about this. Basically if your write the string into your program code: "Hello World" then the compiler puts the null character at the end of the string when you use it in an assignment statement ( right hand side of an equal sign (i.e. : char array[10] = "Hello World";). If you write a loop like you did in post #5 then the compiler DOES NOT add the null termination character, you must do it. |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5027 浏览 9 评论
1928 浏览 8 评论
1865 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3081 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2153 浏览 5 评论
590浏览 1评论
454浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
486浏览 0评论
385浏览 0评论
IPECMD命令烧录AVR128DA48芯片,报找不到芯片错误
867浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-28 10:24 , Processed in 1.333883 second(s), Total 76, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191