Advertisement
codemonkey

Untitled

Sep 1st, 2011
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 KB | None | 0 0
  1.   1 #include <stdio.h>
  2.   2 #include <string.h>
  3.   3 #define USAGE(err) printf("USAGE: fibo [number]\nError: %s", err)
  4.   4
  5.   5 typedef char* string;
  6.   6
  7.   7 // Returns the specified index from the fibonacci range
  8.   8 int fibo_index(int index);
  9.   9
  10.  10 // Returns the fibonacci range until the specified limit
  11.  11 void fibo(int* output, int limit);
  12.  12
  13.  13 // Main function
  14.  14 int main(int argc, const char** args)
  15.  15 {
  16.  16     // Application expects 2 arguments
  17.  17     if(argc != 2)
  18.  18     {
  19.  19         string error;
  20.  20         sprintf(error, "Got %d arguments", argc);
  21.  21
  22.  22         USAGE(error);
  23.  23     }
  24.  24     else
  25.  25     {
  26.  26         int input;
  27.  27
  28.  28         if(sscanf("%d", args[1], &input))
  29.  29         {
  30.  30             printf("Success! Number is %d", input);
  31.  31         }
  32.  32         else
  33.  33         {
  34.  34             USAGE(strcat("Input was not a valid number: ", args[1]));
  35.  35         }
  36.  36     }
  37.  37
  38.  38     printf("\n");
  39.  39 }
  40.  40
  41.  41 int fibo_index(int index)
  42.  42 {
  43.  43
  44.  44 }
  45.  45
  46.  46 void fibo(int* output, int limit)
  47.  47 {
  48.  48
  49.  49 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement