summaryrefslogtreecommitdiff
path: root/userspace/add.c
blob: 17ddb641b95d1a5c8b0bc07306859d8742071874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <string.h>
#include "syscalls.c"
#include "../fs/fs.h"


int main(int argc, char **argv) 
{
    syscalls_init();

    FILE *input;
    input=fopen(1,"r");
    char *buf=malloc(256);

    int sum=0;
    int i=0;

    while(1)
    {
	printf("enter numer %i: ",i+1);
        fgets(buf,255,input);
	if(buf[1]=='x')break;
	i++;
	sum+=atoi(buf);

    }

    printf("sum = %i \n",sum);
    printf("avg = %i \n\n",sum/i);

    execve(15,0,0);
}