-
Notifications
You must be signed in to change notification settings - Fork 1
/
sorter_client.h
71 lines (56 loc) · 1.37 KB
/
sorter_client.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*****
*
* Define structures and function prototypes for your sorter
*
*
*
******/
/* Struct for each movie in CSV file. Each movie contains 28 fields that describe it according to IMDB. */
typedef struct movie {
char *color;
char *directorName;
int numCriticReviews;
int duration;
int directorFBlikes;
int actor3FBlikes;
char *actor2name;
int actor1FBlikes;
int gross;
char *genres;
char *actor1name;
char *movieTitle;
int numVotedUsers;
int castTotalFBlikes;
char *actor3name;
int faceNumberPoster;
char *plotKeywords;
char *link;
int numUserReviews;
char *language;
char *country;
char *contentRating;
int budget;
int titleYear;
int actor2FBlikes;
double imdbScore;
double aspectRatio;
int movieFBlikes;
} movie;
/* Trims/removes leading and trailing spaces in a string */
void trim(char* token) {
if(token[0] == ' '){ //leading white spaces
int i, j;
for(i = 0; token[i] == ' '; i++);
for(j = 0; token[i+j] != '\0'; j++){
token[j] = token[i+j];
}
token[j] = '\0';
}
if(token[strlen(token)] == ' ' || token[strlen(token)] == '\0'){ //trailing white spaces
int i = strlen(token);
while(token[i] == ' ' || token[i] == '\0'){
i--;
}
token[i + 1] = '\0';
}
} //end of 'trim' function