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