File: copy_doubles.c

package info (click to toggle)
garlic 1.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,492 kB
  • ctags: 1,013
  • sloc: ansic: 29,925; makefile: 753
file content (60 lines) | stat: -rw-r--r-- 1,216 bytes parent folder | download | duplicates (6)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* Copyright (C) 2000 Damir Zucic */

/*=============================================================================

				copy_doubles.c

Purpose:
	Copy digits, signs and decimal points. Replace anything else with
	space.

Input:
	(1) Output string pointer.
	(2) Input string pointer.
	(3) The number of characters to be copied.

Output:
	(1) Output string.

Return value:
	No return value.

========includes:============================================================*/

#include <stdio.h>

#include <ctype.h>

/*======copy digits, signs and decimal points:===============================*/

void CopyDoubles_ (char *output_stringP, char *input_stringP, int charsN)
{
int		i, n;

/* Fill the output string with zeros (the number of zeros is charsN): */
for (i = 0; i < charsN; i++) *(output_stringP + i) = '\0';

/* Copy digits, signs and decimal points: */
for (i = 0; i < charsN; i++)
	{
	n = *(input_stringP + i);
	if (n == '\0')
		{
		*(output_stringP + i) = '\0';
		break;
		}
	if (isdigit (n) || (n == '-') || (n == '+') || (n == '.'))
		{
		*(output_stringP + i) = n;
		}
	else
		{
		*(output_stringP + i) = ' ';
		}
	}

}

/*===========================================================================*/