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

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

#include <stdio.h>
#include <basic.h>
#include <common.h>

Go to the source code of this file.

Functions

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

Detailed Description

Some common functions used here and there.

Author
Debojyoti Ghosh

Definition in file CommonFunctions.c.

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