summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrafa_99 <rafa99@protonmail.com>2020-09-23 09:53:39 +0100
committerrafa_99 <rafa99@protonmail.com>2020-09-23 09:53:39 +0100
commit8771b02f37a762cbec63cc92dc313148d0f9b2a6 (patch)
tree69bab53bc47ced316e13afe9285af6964911a551
parent72f813b35638efdc298967d0f7b90f5110370163 (diff)
Converted Argument to Unique String
-rw-r--r--pkg.c2
-rw-r--r--utils.c15
-rw-r--r--utils.h1
3 files changed, 18 insertions, 0 deletions
diff --git a/pkg.c b/pkg.c
index 3396e44..3b1698c 100644
--- a/pkg.c
+++ b/pkg.c
@@ -8,5 +8,7 @@
int main(int argc, char **argv)
{
+ char* arg = stringedArgument(argc, argv);
+ free(arg);
return 0;
}
diff --git a/utils.c b/utils.c
index d270436..24ff43f 100644
--- a/utils.c
+++ b/utils.c
@@ -1,4 +1,6 @@
#include "utils.h"
+#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
int checkIfFileExists(char *path)
@@ -43,3 +45,16 @@ int detectOsType()
}
return exists;
}
+
+char* stringedArgument(int argc, char** argv)
+{
+ int numberOfTotalPackages = argc - 2;
+ char* arg = (char *) calloc((numberOfTotalPackages * 80), sizeof(char));
+
+ for( int i = 2; i < argc; i++ )
+ {
+ strcat(arg, argv[i]);
+ strcat(arg, " ");
+ }
+ return arg;
+}
diff --git a/utils.h b/utils.h
index 12b0eb1..7965542 100644
--- a/utils.h
+++ b/utils.h
@@ -15,3 +15,4 @@ enum os
int checkIfFileExists(char *path);
int detectOsType();
+char* stringedArgument(int argc, char** argv);