Example Of Use - HP eld Manual

Table of Contents

Advertisement

Introduction to eld

Example of Use

This section shows an example of using the
a main program, mainstrc, and a library called mystrngc. Both will be compiled using
ccomp, then linked using eld. mystrngc will be loaded as a DLL.
Display the Source Code
Here is the code for the main program, mainstrc
#include <stdio.h>
#include <stdlib.h> nolist
#include <string.h> nolist
int StrRev (char *s, char *r); /* declaration of external procedure */
char s[100];
/***********************************************************
|
main: given a list of strings, print out them reversed
|
argv[1]...argv[argc-1] point to strings
|
|
if no string passed, put out usage message and quit.
|
for each string
|
reverse it
|
display it
|
\***********************************************************/
int main(int argc, char *argv[]) {
char **ppStr;
int strLeft;
int outcome;
if (argc < 2)
{
printf("Usage: run rev <str1> [<str2>] ....\n \
exit(1);
}
for (strLeft= argc-1, ppStr=argv+1;
strLeft;
ppStr++, strLeft-- ) {
strcpy(s, *ppStr);
outcome = StrRev( s, s );
(outcome == 0) ? printf( "Reverse(%s) = (%s)\n", *ppStr, s ) :
} /* for */
printf("Hit enter to finish\n");
getchar( );
} /* of proc main */
Here is the source code for the library, mystrngc
#include <string.h> nolist
#include <stdlib.h> nolist
int StrRev (char *s, char *r ) {
nolist
/* no args passed */
\twhere <str> is a string to reverse\n \
\texample: run rev abc zyxw\n");
printf( "error in reversing the string\n");
eld Manual—527255-009
linker. This example shows the use of
eld
1-9
Example of Use

Advertisement

Table of Contents
loading

Table of Contents