diff options
Diffstat (limited to 'src/video.c')
-rw-r--r-- | src/video.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/video.c b/src/video.c index 0e09437..e48245b 100644 --- a/src/video.c +++ b/src/video.c @@ -1,4 +1,5 @@ #include "../include/video.h" +#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -36,6 +37,54 @@ createVideo (char *title, char *author, char *id, char *duration) } void +printVideo (char *format, Video *videos, int numberOfVideos) +{ + if (format != NULL && strlen (format) > 0) + { + for (int i = 0; i < numberOfVideos; i++) + { + for (int j = 0; j < strlen (format); j++) + { + switch (format[j]) + { + case 'a': + printf ("%s", videos[i].author); + break; + case 'd': + printf ("%s", videos[i].duration); + break; + case 'i': + printf ("%s", videos[i].id); + break; + case 't': + printf ("%s", videos[i].title); + break; + case 'R': + printf ("\n"); + break; + case 'T': + printf ("\t"); + break; + default: + if (!isalpha (format[j])) + { + printf ("%c", format[j]); + } + } + } + printf ("\n"); + } + } + else + { + for (int i = 0; i < numberOfVideos; i++) + { + printf ("%s\t%s\n", videos[i].id, videos[i].title); + } + } +} + +void freeVideo (Video *v) { free (v->title); |