I can't tell where is the problem, i need this to be done and work. I have the source here and i ask for help.
I think that this program runs only on unix, i want to get this work on knoppix. Note that i am not so good on this.
avg.x

/*
 * The average procedure receives an array of real 
 * numbers and returns the average of their 
 * values. This toy service handles a maximum of 
 * 200 numbers.
 */
const MAXAVGSIZE  = 200;

struct input_data {
  double input_data<200>;
};

typedef struct input_data input_data;

program AVERAGEPROG {
    version AVERAGEVERS {
        double AVERAGE(input_data) = 1;
    } = 1;
} = 22855;
--------------------------------
avg_svc.c

#include "avg.h"
#include <stdlib.h>

void
averageprog_1( char* host, int argc, char *argv[])
{
   CLIENT *clnt;
   double  *result_1, *dp, f;
      char *endptr;
      int i;
   input_data  average_1_arg;
     average_1_arg.input_data.input_data_val = 
     (double*) malloc(MAXAVGSIZE*sizeof(double));
     dp = average_1_arg.input_data.input_data_val;
     average_1_arg.input_data.input_data_len = 
         argc - 2;
      for (i=1;i<=(argc - 2);i++) {
        f = strtod(argv[i+1],&endptr);
        printf("value   = %e\n",f);
        *dp = f;
        dp++;
      }
   clnt = clnt_create(host, AVERAGEPROG, 
        AVERAGEVERS, "udp");
   if (clnt == NULL) {
      clnt_pcreateerror(host);
      exit(1);
   }
   result_1 = average_1(&average_1_arg, clnt);
   if (result_1 == NULL) {
      clnt_perror(clnt, "call failed:");
   }
   clnt_destroy( clnt );
      printf("average = %e\n",*result_1);
}


main( int argc, char* argv[] )
{
   char *host;

   if(argc < 3) {
     printf(
      "usage: %s server_host value ...\n",
      argv[0]);
      exit(1);
   }
        if(argc > MAXAVGSIZE + 2) {
          printf("Two many input values\n");
          exit(2);
        }
   host = argv[1];
   averageprog_1( host, argc, argv);
}
--------------------------------------
ravg.c
#include <rpc/rpc.h>
#include "avg.h"
#include <stdio.h>

static double sum_avg;

double * average_1(input_data *input, 
        CLIENT *client) {

  double *dp = input->input_data.input_data_val;
  u_int i;
  sum_avg = 0;
  for(i=1;i<=input->input_data.input_data_len;i++) {
    sum_avg = sum_avg + *dp; dp++;
  }
  sum_avg = sum_avg / 
        input->input_data.input_data_len;
  return(&sum_avg);
}

double * average_1_svc(input_data *input, 
        struct svc_req *svc) {
  CLIENT *client;
  return(average_1(input,client));
}
make
BIN =  ravg avg_svc
GEN = avg_clnt.c avg_svc.c avg_xdr.c avg.h
RPCCOM = rpcgen

all: $(BIN)

ravg: ravg.o avg_clnt.o avg_xdr.o
        $(CC) -o $@ ravg.o avg_clnt.o avg_xdr.o 

ravg.o: ravg.c avg.h
        $(CC) -g ravg.c -c

avg_svc: avg_proc.o avg_svc.o avg_xdr.o
        $(CC) -o $@ avg_proc.o avg_svc.o avg_xdr.o<\n> 

avg_proc.o: avg_proc.c avg.h

$(GEN): avg.x
        $(RPCCOM) avg.x

clean cleanup:
        rm -f $(GEN) *.o $(BIN)

What errors does g++ give out when you try to compile it? Which lines are getting the errors? Nothing looks seriously wrong with your code.

It's also a good idea to put int in front of main(), because although int type is default on most compilers, it's much safer to manually specify it.

And please use code tags - more information in my signature. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.