HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
common.h File Reference

Some common functions used here and there. More...

Go to the source code of this file.

Functions

void GetStringFromInteger (int, char *, int)
 

Detailed Description

Some common functions used here and there.

Author
Debojyoti Ghosh

Definition in file common.h.

Function Documentation

◆ GetStringFromInteger()

void GetStringFromInteger ( int  a,
char *  A,
int  width 
)

Get a string corresponding to an integer, i.e. 41 gives "00041" if width is 5, or "41" if width is 2, or "1" if width is 1.

Parameters
athe integer to convert to a string
Athe string
widthdesired width of the string

Definition at line 15 of file CommonFunctions.c.

20 {
21  if (width > _MAX_STRING_SIZE_-1) {
22  fprintf(stderr,"Error in GetStringFromInteger(): requested width is larger than _MAX_STRING_SIZE_.\n");
23  }
24  int i;
25  for (i=0; i<width; i++) {
26  char digit = (char) (a%10 + '0');
27  a /= 10;
28  A[width-1-i] = digit;
29  }
30  A[width] = 0;
31  return;
32 }
#define _MAX_STRING_SIZE_
Definition: basic.h:14