source: experiments/Divide_job_id/a.c @ 16

Revision 16, 1.1 KB checked in by mmatloka, 14 years ago (diff)

add experiments

Line 
1#include <stdlib.h>
2#include <string.h>
3#include <stdio.h>
4
5void divide(char * job_id)
6{
7        char * a,b,c,temp,pta;
8        /*a = (char *)malloc(30*sizeof(char*));
9        b = (char *)malloc(30*sizeof(char*));
10        c = (char *)malloc(30*sizeof(char*));*/
11        /*temp = (char *)malloc(30*sizeof(char*));*/
12        int i;
13        /*temp = strdup(job_id);*/
14        /*size_t l = strspn(job_id,".");*/
15        /*strncpy(a, job_id, strchr(job_id,'.') - job_id );*/
16        /*strncpy(temp, job_id, strlen(job_id) - strlen(a) -1 );
17        *//*strncpy(b, job_id, strchr(temp,'.') - temp  );*/
18       
19    char *rest;
20    char *token;
21    char *ptr = job_id;
22
23     
24  /*  while(token = strtok_r(ptr, ".", &rest)) {
25
26            printf("%s\n", token);
27            ptr = rest;
28    }*/
29       
30        token = strtok_r(ptr, ".", &rest);
31        printf("%s\n", token);
32    ptr = rest;
33        token = strtok_r(ptr, ".", &rest);
34        printf("%s\n", token);
35    ptr = rest;
36        token = strtok_r(ptr, ".", &rest);
37        printf("%s\n", token);
38    ptr = rest;
39       
40        /*for(i = 0;i<strlen(job_id);i++)
41        {
42                if(job_id[i] == ".")
43               
44        }*/
45       
46       
47       
48       
49
50}
51
52int main(int argc, char *argv[])
53{
54        if(argc<2)
55                exit(1);
56       
57        divide(argv[1]);
58        return 0;
59}
Note: See TracBrowser for help on using the repository browser.