Python, writing to file

Started by
1 comment, last by V-man 15 years, 9 months ago
In order to write to my file mystring="mystring"; file.write(mystring); but it doesn't write the NULL char I believe. I need to write the NULL char as well due to the file format requirement. Do I have to do another file.write command to just write a 8 bit 0 value? What would the code look like?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Advertisement
Quote:Original post by V-man
In order to write to my file

mystring="mystring";
file.write(mystring);

but it doesn't write the NULL char I believe. I need to write the NULL char as well due to the file format requirement.
Do I have to do another file.write command to just write a 8 bit 0 value? What would the code look like?


You should be able to just add the NULL char at the end using the following
statement: mystring = "mystring\0"

** boolean010 **
Thanks for the quick reply, that worked.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement