eng01015 wrote:May I know what would the 'NULL' chars look like if i write it to a .txt file? Is it just blank spaces, or should it be "squares"?
It depends on how you show them on the screen in your program or which editor you use to open the file.
For example, editor called VIM on Unix will show "^@" marks meaning NULL in a file. I'm kinda interested to know how windows notepad handles that situation, try this program:
- Code: Select all
#include <stdio.h>
int main () {
char ptr[] = "this is a \0string\0";
FILE *fp;
fp=fopen("string.txt","w");
fwrite(ptr,1,18,fp);
fclose(fp);
}
Run it and open "string.txt" using Notepad and see what happens. Try changing "w" to "wb" and see what's the difference. On Unix this makes no difference at all, binary and text are handled the same way.