I'll give you some small hints as well Halkun.
Dunno if it will work for you, but mine C++ compiler can compile this:
char name[] = "Something";
that means it does not need the array size definition if you define the string right after it. Makes it nicer.
Also array can be translated as a pointer to the array members ... that means that char name[ 8 ]; - name can be used as char* ... int data[ 8 ]; data is int* as well. But in some cases it won't work.
for your information all the char[] char* strings in C are required to have a zero byte ( or '\0' char ) on their end. That's what marks the end of string. If you create a string like char name[ 8 ]; its contents are undefined, it can contain 8x "A" which means that it is not ended anywhere - that means any operation on it would end up randomly, probably reading / writing in some invalid memory. You should allways fill up your variables, you can't expect them to reset automatically. Good way is to:
char name[ 8 ] = { 0 };
or
char name[ 8 ];
name[0] = 0; <- sets the first byte to zero, which means start of string is also its end.
This means another complication which some people overlook. If you have char name[ 8 ]; and you use it as a string you can't fill it with 8 characters. Because there has to be space for the zero ending character. So it can contain max 7 chars + 1 zero character.
strcpy( name, "12345678" ); will copy 8 characters into the 'name' variable, and it will write the 9th zero character outside - somewhere to undefined memory. It can work, right, but it also can overwrite some important variable memory.
C++ overcomes all these problems with dynamic std::string<> which takes care about the space the string needs ... but it also brings another problems
About the function ... I was reading the man page and I found:
TCL_LINK_STRING The C variable is of type char *.
If its value is not null then it must be a pointer to a string allocated with Tcl_Alloc. Whenever the Tcl variable is modified the current C string will be freed and new memory will be allocated to hold a copy of the variable's new value. If the C variable contains a null pointer then the Tcl variable will read as ``NULL''.
which brings me to the conclusion that you have to alloc the variable in a special way as it could be changed / resized when some other string changes. So maybe you should use it this way:
Tcl_Interp inter; // returned error code
char varname[] = "Variable"; // variable name
char* newstring = Tcl_Alloc( default_size_of_your_string );
strcpy( newstring, "hello" );
Tcl_LinkVar( &inter, varname, newstring, TCL_LINK_STRING );
// check for return code
if ( inter == something )
do something.
// and maybe somewhere at the end you should free the string
Tcl_Free( newstring );
Well this is just my guess from the man page ... dunno if its correct because I don't know the lib ... also some thing puzzle me ... why should be the varname changed and how ? Maybe it should be specially allocated as well ? Maybe if thou do not want to define the string you don't have to alloc it and you can use NULL parameter instead Tcl_LinkVar( &inter, varname, NULL, TCL_LINK_STRING ); ?
It'd be better if you would see for some examples used with this function to see the proper usage.