Project

General

Profile

Bug #11765 ยป add.c

lxh37 (Liz Huang), 12/02/2015 08:11 PM

 
1
//
2
//  add.c
3
//  add
4
//
5
//  Created by lxh37 on 11/19/2015.
6
//  Copyright (c) 2014 Penn State. All rights reserved.
7
//
8

    
9

    
10
#include <stdio.h>
11
#include <stdlib.h>
12
#include <string.h>
13

    
14
//extern long addsize(long maxn, double delta, double conf, long msgLen, int *iMsg);
15
//extern long addsize(long maxn, double delta, double conf);
16
extern addsize(long maxn, double delta, double conf, long *answer);
17

    
18
long add(long maxn, double delta, double conf, char *errMsg)
19
{
20
        long ERR_MSG_LENGTH, answer;
21
        unsigned i;
22
        //int *iarr;
23
        char * iarr;
24

    
25
       // answer = (long)(maxn + delta + conf);
26
       iarr = "Hello!";
27
    
28
       // ERR_MSG_LENGTH=100;
29
	//iarr = (int *) malloc(ERR_MSG_LENGTH*sizeof(int));
30
	//for (i=0; i < ERR_MSG_LENGTH; i++) iarr[i] = (int) ' ';
31

    
32
       // answer = addsize(maxn, delta, conf);
33
       addsize(maxn, delta, conf, &answer);
34

    
35
        for (i=0; ((char) iarr[i]) != '\0'; ++i) errMsg[i] = (char) iarr[i];
36
        errMsg[i] =  '\0';
37
        return answer;
38
}
39

    
40
char * cp(char *dest, const char *src)
41
{
42
  unsigned i;
43
  for (i=0; src[i] != '\0'; ++i)
44
    dest[i] = src[i];
45
  dest[i] = '\0';
46
  return dest;
47
}
48