home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
editors
/
hypsh40b.arj
/
HYPDEVEL.LZH
/
CHILD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-04-24
|
1KB
|
79 lines
/*
CHILD.C
Copyright (c) Text Technology 1990
Example program to be run from HyperShell
to access variables whose addresses are
passed in the command line
Requires Turbo-C
*/
#include <stdio.h>
#include <dos.h>
#include <string.h>
/*
Simple example displays received value, awaits
input of new value, sets new value and exits
*/
main(argc, argv)
int argc;
char **argv;
{
char var[80];
getvariable(argv[1],var);
printf("Received %s\nEnter string to return: ", var);
gets(var);
putvariable(argv[1],var);
exit(0);
}
/*
GETVARIABLE
gets contents of variable whose address is in addstr
and places it in tostr (this needs to be pre-allocated)
*/
getvariable(addstr,tostr)
char *addstr;
char *tostr;
{
char far *variable;
sscanf(addstr,"%Fp", (void far *)&variable);
sprintf(tostr, "%Fs", (char far *)variable);
return(0);
}
/*
PUTVARIABLE
sets contents of variable whose address is in addstr
to value from fromstr
*/
putvariable(addstr,fromstr)
char *addstr;
char *fromstr;
{
char far *variable;
sscanf(addstr,"%Fp", (void far *)&variable);
/* cannot use strcpy, have to do own copy */
while(*variable++ = *fromstr++)
/* null statement - work done in while */
;
return(0);
}
/* end of source program */