Skip to content

Instantly share code, notes, and snippets.

@maksadbek
Last active December 21, 2015 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maksadbek/6283393 to your computer and use it in GitHub Desktop.
Save maksadbek/6283393 to your computer and use it in GitHub Desktop.
int2char'n char2int in C++
//from int to char
while(n>0){
ch[i]=(n%10)+'0';
n=n/10;
i++;
}
while(i>0){
putchar(ch[i-1]);
i--
}
//from char to int
while(ch >= '0' && ch <= '9')
{
n=(n<<3)+(n<<1)+ch-'0',ch=getchar()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment