Quick $15 for a short C program posted here via paypal

Discussion in 'Programming' started by JTCentral, Jul 20, 2009.

  1. #1
    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
     
    JTCentral, Jul 20, 2009 IP
  2. facticatech

    facticatech Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Hi,

    I can code the C program as per ur requirements. let me know. my email facticatech AT gmail D0T C0M
     
    facticatech, Jul 21, 2009 IP
  3. karthimx

    karthimx Prominent Member

    Messages:
    4,959
    Likes Received:
    127
    Best Answers:
    2
    Trophy Points:
    340
    As Seller:
    100% - 72
    As Buyer:
    100% - 0
    #3
    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 ...
     
    karthimx, Jul 21, 2009 IP
  4. karthimx

    karthimx Prominent Member

    Messages:
    4,959
    Likes Received:
    127
    Best Answers:
    2
    Trophy Points:
    340
    As Seller:
    100% - 72
    As Buyer:
    100% - 0
    #4
    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 ;
    }
     
    karthimx, Jul 21, 2009 IP
  5. JTCentral

    JTCentral Well-Known Member

    Messages:
    211
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    160
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    PM your paypal addy
     
    JTCentral, Jul 21, 2009 IP
  6. karthimx

    karthimx Prominent Member

    Messages:
    4,959
    Likes Received:
    127
    Best Answers:
    2
    Trophy Points:
    340
    As Seller:
    100% - 72
    As Buyer:
    100% - 0
    #6
    Got the payment thanks.
     
    karthimx, Jul 21, 2009 IP