View Single Post
  #4 (permalink)  
Old 10-30-2005, 02:56 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Null-terminated strings

Quote:
Originally Posted by newdigital
You described that we should write a null character after the last character of data in data type string.

But it was nothing in the examples:
string str1 = "Hello";

So no null.

May be it was for the explanation only?
Hi newdigital,

Thank you very much for your question, it's an intelligent one.
This kind of strings (and it's the only kind MQL4 uses) called Null-terminated strings


The NULL has putted for you automatically when you used the "string" keyword to create a string type variable.

So you must not add NULL to the end of your string, because MQL4 will add it automatically.

string str1 = "Hello"; will be presented in the memory like that:

H e l l o NULL
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm

Last edited by newdigital; 10-30-2005 at 04:12 PM.
Reply With Quote