Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "string.h"
- #include <stdio.h>
- #define LENGTH 40
- #define DATE_LEN 8
- typedef struct position
- {
- char name[LENGTH];
- char start[DATE_LEN];
- char end[DATE_LEN];
- }POSITION;
- char* buildval(POSITION p)
- {
- char *t = p.start;
- char *ans;
- while (*t != NULL && *t != '#')
- {
- *t = *ans;
- t++;
- ans++;
- }
- }
- void movearrAndExpand (POSITION jobs[], int sizejobs, int fromwhere)
- {
- for ( ; fromwhere < sizejobs-1; fromwhere++)
- {
- POSITION tmp = jobs[fromwhere];
- jobs[fromwhere+1] = jobs[fromwhere];
- jobs[fromwhere+2] = tmp;
- }
- realloc(jobs,1);
- }
- void insertjob(POSITION jobs[] , int size, POSITION tmp)
- {
- char* eval = buildval(tmp);
- int flag = 1;
- for (int i = 0 ; i < size && flag ; i++)
- {
- if (strcmp(buildval(jobs[i]),eval) == 1)
- {
- movearrAndExpand(jobs,size,i+1);
- }
- }
- }
- POSITION* ReadChron(int* num_jobs)
- {
- POSITION* p = malloc((*num_jobs)*sizeof(POSITION));
- POSITION newp = {"engineer", "11#2003" , "12#2006"};
- insertjob(p, *num_jobs, newp);
- }
- void main()
- {
- POSITION* jobs = NULL;
- int num_jobs;
- jobs= ReadChron(&num_jobs);
- printf("list of jobs:\n");
- //showJobs(jobs,num_jobs);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement