AD1

Thursday, 2 February 2017

string of numbers

write a function that accepts string of numbers and converts it to digits 
as example convert("123")=123

#include <stdio.h>
void convert(char *base)// passing array to a function
{
while(*base!='\0')
{
*base-='0';//*base=*base-'0' will give you the numeric value of character number
printf("%d",*base);
base++;
}
}
int main()
{
char num_char[5]="83461";
convert(num_char);
return 0;
}
view raw convert.c hosted with ❤ by GitHub


No comments:

Post a Comment