Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- char* monthSearch(char month[]);
- void optionOne(int argc, char* argv[]);
- void optionTwo(int argc, char* argv[]);
- void optionThree(int argc, char* argv[]);
- int main(int argc, char* argv[]){
- if (strcmp(argv[1],"-f1") == 0)
- optionOne(argc, argv);
- else if (strcmp(argv[1],"-f2") == 0)
- optionTwo(argc, argv);
- else if (strcmp(argv[1],"-f3") == 0)
- optionThree(argc, argv);
- return 0;
- }
- void optionOne(int argc, char* argv[]){
- int token = 2000 + atoi(argv[4]);
- char *p;
- p = monthSearch(argv[3]);
- printf("%s de %s de %d \n",argv[2],p,token);
- }
- void optionTwo(int argc, char* argv[]){
- int token = 2000 + atoi(argv[4]);
- printf("%s/%s/%d \n",argv[2],argv[3],token);
- }
- void optionThree(int argc, char* argv[]){
- int i,token = 2000 + atoi(argv[4]);
- char *p;
- p = monthSearch(argv[3]);
- printf("%s-",argv[2]);
- for(i = 0; i<3; i++)
- printf("%c",p[i]);
- printf("-%d \n",token);
- }
- char* monthSearch(char month[]){
- int digit = atoi(month);
- char s[15];
- if(digit == 1)
- strcpy(s, "janeiro");
- else if(digit == 2)
- strcpy(s, "fevereiro");
- else if(digit == 3)
- strcpy(s, "marco");
- else if(digit == 4)
- strcpy(s, "abril");
- else if(digit == 5)
- strcpy(s, "maio");
- else if(digit == 6)
- strcpy(s, "junho");
- else if(digit == 7)
- strcpy(s, "julho");
- else if(digit == 8)
- strcpy(s, "agosto");
- else if(digit == 9)
- strcpy(s, "setembro");
- else if(digit == 10)
- strcpy(s, "outubro");
- else if(digit == 11)
- strcpy(s, "novembro");
- else
- strcpy(s, "dezembro");
- char *p = s;
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment