HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
IncrementFilename.c
Go to the documentation of this file.
1
6
#include <stdio.h>
7
9
// i.e., the number represented by the string nnnnn is incremented
10
// by 1.
11
//*/
12
//void IncrementFilename(char *f /*!< filename */)
13
//{
14
// if (f[7] == '9') {
15
// f[7] = '0';
16
// if (f[6] == '9') {
17
// f[6] = '0';
18
// if (f[5] == '9') {
19
// f[5] = '0';
20
// if (f[4] == '9') {
21
// f[4] = '0';
22
// if (f[3] == '9') {
23
// f[3] = '0';
24
// fprintf(stderr,"Warning: file increment hit max limit. Resetting to zero.\n");
25
// } else {
26
// f[3]++;
27
// }
28
// } else {
29
// f[4]++;
30
// }
31
// } else {
32
// f[5]++;
33
// }
34
// } else {
35
// f[6]++;
36
// }
37
// } else {
38
// f[7]++;
39
// }
40
//}
41
46
void
IncrementFilenameIndex
(
47
char
*f,
48
int
len
49
)
50
{
51
int
i;
52
for
(i=len-1; i>=0; i--) {
53
if
(f[i] ==
'9'
) {
54
f[i] =
'0'
;
55
if
(!i) fprintf(stderr,
"Warning: file increment hit max limit. Resetting to zero.\n"
);
56
}
else
{
57
f[i]++;
58
break
;
59
}
60
}
61
}
62
64
void
ResetFilenameIndex
(
char
*f,
65
int
len )
66
{
67
if
(!f)
return
;
68
int
i;
69
for
(i = 0; i < len; i++) {
70
f[i] =
'0'
;
71
}
72
return
;
73
}
IncrementFilenameIndex
void IncrementFilenameIndex(char *f, int len)
Definition:
IncrementFilename.c:46
ResetFilenameIndex
void ResetFilenameIndex(char *f, int len)
Definition:
IncrementFilename.c:64