write a function that accepts string of numbers and converts it to digits
as example convert("123")=123
as example convert("123")=123
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
No comments:
Post a Comment