Sponsored Content
Top Forums Programming Returning local string value from a function in C Post 302523834 by vistastar on Friday 20th of May 2011 02:39:35 AM
Old 05-20-2011
a) It's platform dependent. In most cases you need not, for example, linux, windows xp or latter. In DOS, a string literal may be modified.
b) The value of returned pointer(ie. the address of the pointer) can't be modified.
c) You just read, no write, so it is is re-entrant.
d) There's no reference type in C.
 

10 More Discussions You Might Find Interesting

1. Programming

string returning function

I have two string returning function in ESQL/C char *segment_name(lbuffer) char *lbuffer; {..... and char *get_bpdvalue(f_name) char *f_name; {...... both declared above main() char *get_bpdvalue(); char *segment_name(); my problem is segment_name works on sprintf and strcpy... (5 Replies)
Discussion started by: jisc
5 Replies

2. Programming

create a thread from a returning function

hi all, my requirement is to create a thread by calling another function. i.e i dont call pthread_create directly from main, but by calling another function (createThd - below ), from main. Example: void *thread_function(void *arg) { /* thread function */ int i; rc =... (3 Replies)
Discussion started by: wolwy_pete
3 Replies

3. Shell Programming and Scripting

returning from a function

Hi all, I am very new to BASH shell programming. I need to return an integer from a function to the caller function. I did this: but it keeps giving me wrong return: Can someone help me out here, please? Thanks (2 Replies)
Discussion started by: alirezan
2 Replies

4. Programming

returning multiple values from a function in C

hi how can I return multiple values from a C function. I tried the following: #include <stdio.h> void foo(int id, char *first_name, char *last_name) { /* this is just an example to illustrate my problem... real code makes use of the "id" parameter. */ first_name = (char... (8 Replies)
Discussion started by: Andrewkl
8 Replies

5. Shell Programming and Scripting

Returning the name of function used

Hi All In my script, I can call on several functions. I have a logging function that is called by any of these functions. What I would like is some way of identifying which function I am using and pass this to the log function as some parameter. Is there some built in command or way of... (3 Replies)
Discussion started by: kingpin2502
3 Replies

6. Programming

Function Returning Value w/o return stmt

I am working on a C/Unix application from last 2 years which communicates with other systems using proprietary format of my client. We have a function written in C which returns integer, which is response from other system to the request message initiated by my system. This return value is then... (1 Reply)
Discussion started by: dpmore
1 Replies

7. Programming

segmentation fault while returning from function.

I am working on the application in which I have to fetch values from the database and paste in url and send it to portal. table=get_result("SELECT serialno,cas,Mode,FLC,TLC,location,CompName,CompCode,FG,FC,DispNo,TruckNo,LWbill,RRGPN,INVNO,DCN,RQTY,DQTY,SQTY,DDATE,RDATE,SDATE,TTIME FROM... (1 Reply)
Discussion started by: er.rohan88
1 Replies

8. Programming

Function Returning Pointer

Hi guys. how a functions such fdopen, ... can return pointer? are these functions use static memory(variables)? (6 Replies)
Discussion started by: majid.merkava
6 Replies

9. Programming

Function main returning int?

H friends, As we know, a function returns a value and that value is saved somwhere. like int Sum( int x, int y ) { return x + y; } Total = Sum( 10, 20 ); The value 30 is saved in variable Total. Now the question is, what int value does the function main return, and where is it... (5 Replies)
Discussion started by: gabam
5 Replies

10. Programming

Malloc function returning NULL

Hi All, I am using malloc function for allocating dynamic memory. When I am using below code on Linux server its working fine, but When I am trying the same code on HP UNIX server its returning NULL. below is a fragment of code in which it is giving problem. tmp = (format_tree... (4 Replies)
Discussion started by: Taher Saifuddin
4 Replies
Tcl_LinkVar(3)						      Tcl Library Procedures						    Tcl_LinkVar(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tcl_LinkVar, Tcl_UnlinkVar, Tcl_UpdateLinkedVar - link Tcl variable to C variable SYNOPSIS
#include <tcl.h> int Tcl_LinkVar(interp, varName, addr, type) Tcl_UnlinkVar(interp, varName) Tcl_UpdateLinkedVar(interp, varName) ARGUMENTS
Tcl_Interp *interp (in) Interpreter that contains varName. Also used by Tcl_LinkVar to return error messages. const char *varName (in) Name of global variable. char *addr (in) Address of C variable that is to be linked to varName. int type (in) Type of C variable. Must be one of TCL_LINK_INT, TCL_LINK_UINT, TCL_LINK_CHAR, TCL_LINK_UCHAR, | TCL_LINK_SHORT, TCL_LINK_USHORT, TCL_LINK_LONG, TCL_LINK_ULONG, TCL_LINK_WIDE_INT, TCL_LINK_WIDE_UINT, | TCL_LINK_FLOAT, TCL_LINK_DOUBLE, TCL_LINK_BOOLEAN, or TCL_LINK_STRING, optionally OR'ed with TCL_LINK_READ_ONLY to make Tcl variable read-only. _________________________________________________________________ DESCRIPTION
Tcl_LinkVar uses variable traces to keep the Tcl variable named by varName in sync with the C variable at the address given by addr. When- ever the Tcl variable is read the value of the C variable will be returned, and whenever the Tcl variable is written the C variable will be updated to have the same value. Tcl_LinkVar normally returns TCL_OK; if an error occurs while setting up the link (e.g. because varName is the name of array) then TCL_ERROR is returned and the interpreter's result contains an error message. The type argument specifies the type of the C variable, and must have one of the following values, optionally OR'ed with TCL_LINK_READ_ONLY: TCL_LINK_INT The C variable is of type int. Any value written into the Tcl variable must have a proper integer form acceptable to Tcl_GetIntFro- mObj; attempts to write non-integer values into varName will be rejected with Tcl errors. | TCL_LINK_UINT | The C variable is of type unsigned int. Any value written into the Tcl variable must have a proper unsigned integer form acceptable | to Tcl_GetWideIntFromObj and in the platform's defined range for the unsigned int type; attempts to write non-integer values (or | values outside the range) into varName will be rejected with Tcl errors. | TCL_LINK_CHAR | The C variable is of type char. Any value written into the Tcl variable must have a proper integer form acceptable to Tcl_GetInt- | FromObj and be in the range of the char datatype; attempts to write non-integer or out-of-range values into varName will be rejected | with Tcl errors. | TCL_LINK_UCHAR | The C variable is of type unsigned char. Any value written into the Tcl variable must have a proper unsigned integer form accept- | able to Tcl_GetIntFromObj and in the platform's defined range for the unsigned char type; attempts to write non-integer values (or | values outside the range) into varName will be rejected with Tcl errors. | TCL_LINK_SHORT | The C variable is of type short. Any value written into the Tcl variable must have a proper integer form acceptable to Tcl_GetInt- | FromObj and be in the range of the short datatype; attempts to write non-integer or out-of-range values into varName will be | rejected with Tcl errors. | TCL_LINK_USHORT | The C variable is of type unsigned short. Any value written into the Tcl variable must have a proper unsigned integer form accept- | able to Tcl_GetIntFromObj and in the platform's defined range for the unsigned short type; attempts to write non-integer values (or | values outside the range) into varName will be rejected with Tcl errors. | TCL_LINK_LONG | The C variable is of type long. Any value written into the Tcl variable must have a proper integer form acceptable to Tcl_Get- | LongFromObj; attempts to write non-integer or out-of-range values into varName will be rejected with Tcl errors. | TCL_LINK_ULONG | The C variable is of type unsigned long. Any value written into the Tcl variable must have a proper unsigned integer form accept- | able to Tcl_GetWideIntFromObj and in the platform's defined range for the unsigned long type; attempts to write non-integer values | (or values outside the range) into varName will be rejected with Tcl errors. TCL_LINK_DOUBLE The C variable is of type double. Any value written into the Tcl variable must have a proper real form acceptable to Tcl_GetDouble- FromObj; attempts to write non-real values into varName will be rejected with Tcl errors. | TCL_LINK_FLOAT | The C variable is of type float. Any value written into the Tcl variable must have a proper real form acceptable to Tcl_GetDouble- | FromObj and must be within the range acceptable for a float; attempts to write non-real values (or values outside the range) into | varName will be rejected with Tcl errors. TCL_LINK_WIDE_INT The C variable is of type Tcl_WideInt (which is an integer type at least 64-bits wide on all platforms that can support it.) Any value written into the Tcl variable must have a proper integer form acceptable to Tcl_GetWideIntFromObj; attempts to write non- integer values into varName will be rejected with Tcl errors. | TCL_LINK_WIDE_UINT | The C variable is of type Tcl_WideUInt (which is an unsigned integer type at least 64-bits wide on all platforms that can support | it.) Any value written into the Tcl variable must have a proper unsigned integer form acceptable to Tcl_GetWideIntFromObj (it will | be cast to unsigned); attempts to write non-integer values into varName will be rejected with Tcl errors. TCL_LINK_BOOLEAN The C variable is of type int. If its value is zero then it will read from Tcl as "0"; otherwise it will read from Tcl as "1". Whenever varName is modified, the C variable will be set to a 0 or 1 value. Any value written into the Tcl variable must have a proper boolean form acceptable to Tcl_GetBooleanFromObj; attempts to write non-boolean values into varName will be rejected with Tcl errors. 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 or ckalloc. 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". If the TCL_LINK_READ_ONLY flag is present in type then the variable will be read-only from Tcl, so that its value can only be changed by modifying the C variable. Attempts to write the variable from Tcl will be rejected with errors. Tcl_UnlinkVar removes the link previously set up for the variable given by varName. If there does not exist a link for varName then the procedure has no effect. Tcl_UpdateLinkedVar may be invoked after the C variable has changed to force the Tcl variable to be updated immediately. In many cases this procedure is not needed, since any attempt to read the Tcl variable will return the latest value of the C variable. However, if a trace has been set on the Tcl variable (such as a Tk widget that wishes to display the value of the variable), the trace will not trigger when the C variable has changed. Tcl_UpdateLinkedVar ensures that any traces on the Tcl variable are invoked. KEYWORDS
boolean, integer, link, read-only, real, string, traces, variable Tcl 7.5 Tcl_LinkVar(3)
All times are GMT -4. The time now is 03:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy