xref: /third_party/ltp/testcases/kernel/fs/mongo/summ.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/ltp/testcases/kernel/fs/mongo/
1f08c3bdfSopenharmony_ci/*
2f08c3bdfSopenharmony_ci * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
3f08c3bdfSopenharmony_ci */
4f08c3bdfSopenharmony_ci
5f08c3bdfSopenharmony_ci#include <stdio.h>
6f08c3bdfSopenharmony_ci#include <stdlib.h>
7f08c3bdfSopenharmony_cichar str[100];
8f08c3bdfSopenharmony_ci
9f08c3bdfSopenharmony_ciint main(int argc, char **argv)
10f08c3bdfSopenharmony_ci{
11f08c3bdfSopenharmony_ci	char c, *p;
12f08c3bdfSopenharmony_ci	int sum = 0, n = 0;
13f08c3bdfSopenharmony_ci
14f08c3bdfSopenharmony_ci	p = str;
15f08c3bdfSopenharmony_ci	while ((c = getchar()) != EOF) {
16f08c3bdfSopenharmony_ci		if (c != '\n') {
17f08c3bdfSopenharmony_ci			*p++ = c;
18f08c3bdfSopenharmony_ci		} else {
19f08c3bdfSopenharmony_ci			*p = '\0';
20f08c3bdfSopenharmony_ci			n = atol(str);
21f08c3bdfSopenharmony_ci			sum += n;
22f08c3bdfSopenharmony_ci			printf("%i\n", sum);
23f08c3bdfSopenharmony_ci			p = str;
24f08c3bdfSopenharmony_ci			*p = '\0';
25f08c3bdfSopenharmony_ci		}
26f08c3bdfSopenharmony_ci	}
27f08c3bdfSopenharmony_ci}
28

Indexes created Thu Nov 07 10:32:03 CST 2024