Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How to return a string from a TCL function?

function Return String tcl
0
Posted

How to return a string from a TCL function?

0

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.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123