HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
common_cpp.h File Reference

Some common functions used here and there (C++ declarations) More...

Go to the source code of this file.

Functions

void GetStringFromInteger (int, char *, int)
 

Detailed Description

Some common functions used here and there (C++ declarations)

Author
Debojyoti Ghosh

Definition in file common_cpp.h.

Function Documentation

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