How to return a string from a TCL function?
All you have to do is NOT to declare the function with any data type, and directly return a string type data within the funtion, like the example below: readstr() { char input[80]; input = gets(“\nString: “,40); return input; } This is convenient, but not compatible with Standard C. The incompatibility lies not in the function type declaration but in the way the data returned. In Standard C, a string is a one-dimensional array of character type data, of which the value can not be returned formally. It must be returned by a pointer pointing to the array. However, the TCL may take the one-dimensional character array as a single data type called STRING and therefore, its value can be formally returned by the return statement. Note that the formal way to return an array data in TCL is through the formal argument.