简体   繁体   English

我创建的文件名末尾的多余字符

[英]Extra characters at the end of filenames I create

I am attempting to learn assembler and am having an issue with this tutorial http://www.tutorialspoint.com/assembly_programming/assembly_file_management.htm 我正在尝试学习汇编程序,并且对本教程http://www.tutorialspoint.com/assembly_programming/assembly_file_management.htm有疑问

it works fine and dandy except for when it writes out the file. 它工作正常且繁琐,但写入文件时除外。 Instead of myfile.txt , it is named myfile.txtWelcome to Tutorials PointWritten to file? 取而代之的myfile.txt ,它被命名为myfile.txtWelcome to Tutorials PointWritten to file? .

I can't seem to find out why. 我似乎找不到原因。 I took the source off the tutorial and it does the same thing. 我将源代码从本教程中删除,并且它执行相同的操作。

Can someone tell me why? 有人可以告诉我为什么吗?


I am using nasm 2.12.02. 我正在使用nasm 2.12.02。 I have also tried it on yasm 1.2.0 so I am pretty sure it's the assembler code causing it. 我也在yasm 1.2.0上进行了尝试,因此我很确定这是引起它的汇编代码。

I am building and running on OpenSUSE Linux 3.16.7-35-default #1 SMP Sun Feb 7 17:32:21 UTC 2016 (832c776) x86_64 x86_64 x86_64 GNU/Linux 我正在OpenSUSE Linux 3.16.7-35-default #1 SMP Sun Feb 7 17:32:21 UTC 2016 (832c776) x86_64 x86_64 x86_64 GNU/Linux上构建并运行, OpenSUSE Linux 3.16.7-35-default #1 SMP Sun Feb 7 17:32:21 UTC 2016 (832c776) x86_64 x86_64 x86_64 GNU/Linux

You probably left out a , 0 (zero byte) to terminate the string in the .rodata section where you put the string constants you're using for file names and file data. 您可能遗漏了一个, 0 (零字节)来终止.rodata节中的字符串,在该节中将用于文件名和文件数据的字符串常量放入其中。

Linux system calls (like open(2) ) that take char* args accept zero-terminated C-style strings, instead of accepting a string length. 接受char* args的Linux系统调用(例如open(2) )接受以0结尾的C样式字符串,而不是接受字符串长度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM