Advertisement
feos

div tool

Aug 5th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(int argc, const char *const *const argv)
  6. {
  7.     if (argc == 2)
  8.     {
  9.         const char *p = strchr(argv[1], '/');
  10.         if (p)
  11.         {
  12.             int num = atoi(argv[1]), denom = atoi(p+1);
  13.             if (denom)
  14.             {
  15.                 printf("%f\n", (double)num/(double)denom);
  16.             }
  17.         }
  18.     }
  19.     return(0);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement