My coder is offline for the day and I need quick change to some code I just got. First one to post this gets the $25 I have a Linux C application that.... Takes in arguments (should be 2 items...but can be more) I need code that: If more then two arguments... then loop through the arguments and find the one that begins with /www/ (variable x) Then loop concating those arguments from 0 to x - 1 into var1 then loop concating x - last argument into var2 else save into var1 and var2 end if (I'll insert code here testing var1 and var2 setting a boolean as success or fail) if success..return 1 if failure and the hour in current time is between 00:00 - 01:00 then return 2 else return 0
Hi, I can code the C program as per ur requirements. let me know. my email facticatech AT gmail D0T C0M
let program.out be the executable we can run by passing command line arguments like ./program.out arg1 arg2 arg3 www.website.com arg4 arg5 in this case should i form two variables var1 and var2 such a way that var1 is "arg1 arg2 arg3" and var2 is "www.website.com arg4 arg5" is it what u ment ...
Here is the code that you requested #include <stdio.h> #include <string.h> #include <time.h> int main(int argc , char * argv[]) { int x,i ; char word1[100] =""; char word2[100]="" ; char * var1 = word1 ; char * var2 = word2 ; int ret ; int timereturn ; for(i =1 ; i<argc;i++) { printf("%d value %s\n",i,argv) ; if(strstr((char*)argv,"www")) x=i ; } printf("%d\n",x) ; for (i=1;i<argc-x;i++) { strcat((char*)var1,(char*)argv) ; strcat(var1," ") ; } for (i=x;i<argc;i++) { strcat((char *)var2,(char *)argv) ; strcat(var2," ") ; } printf("%s\n",var1) ; printf("%s\n",var2) ; //check the variables var1 and var2 //ret = urfunction() timereturn = checktime(1) ;//pass ret as argument if(timereturn == 2) printf("time is between 0:00 and 1:00\n") ; else printf("time is not between 0:00 and 1:00\n") ; return 0 ; } int checktime(int ret) { time_t tim; if(ret == 1) return 1 ; else { time(&tim) ; struct tm * timeinfo; timeinfo = localtime ( &tim ); int hour = timeinfo->tm_hour ; if (hour <1) return 2 ; } return 0 ; }