fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int convert (char*s);
  6. int length;
  7.  
  8. int convert (char*s){
  9. int numericValue=0,i;
  10. for ( i = 0; i < length; i++)
  11. {
  12. printf(" address of index[%d] = %x which value is %c \n ", i, s,*s );
  13. numericValue = numericValue * 10 + ( *(s) - '0' );
  14. s++;
  15. }
  16.  
  17. return numericValue;
  18. }
  19.  
  20. int main(){
  21. char p[10];
  22. printf(" please enter numerical string ");
  23. scanf("%s",p);
  24. length=strlen(p);
  25. printf("\n");
  26.  
  27. int number;
  28. number =convert(p);
  29. printf(" returned value %d \n",number);
  30. return 0;
  31. }
Success #stdin #stdout 0s 2116KB
stdin
1270145
stdout
 please enter numerical string 
 address of index[0] = bfa749f6 which value is 1 
  address of index[1] = bfa749f7 which value is 2 
  address of index[2] = bfa749f8 which value is 7 
  address of index[3] = bfa749f9 which value is 0 
  address of index[4] = bfa749fa which value is 1 
  address of index[5] = bfa749fb which value is 4 
  address of index[6] = bfa749fc which value is 5 
  returned value 1270145