use vector instead of pointer
This commit is contained in:
parent
db163511b3
commit
18271ac1d3
2 changed files with 7 additions and 14 deletions
2
result
2
result
|
@ -1 +1 @@
|
|||
/nix/store/765wcp9jrplx6qyjpc30drmkbb04vzkd-desktop-utils-1.0.0
|
||||
/nix/store/ndpfswy7wd40zg6imldcs7l2bpxz77r3-desktop-utils-1.0.0
|
19
src/main.cpp
19
src/main.cpp
|
@ -1,15 +1,15 @@
|
|||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "clients.hpp"
|
||||
|
||||
std::string *splitArgs(int argc, char **argv) {
|
||||
std::vector<std::string> splitArgs(int argc, char **argv) {
|
||||
|
||||
auto result =
|
||||
reinterpret_cast<std::string *>(malloc(sizeof(std::string) * argc));
|
||||
std::vector<std::string> result;
|
||||
for (int i = 1; i < argc; i++) {
|
||||
result[i - 1] = argv[i];
|
||||
result.push_back(argv[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -18,16 +18,9 @@ int main(int argc, char **argv) {
|
|||
|
||||
const auto ARGS = splitArgs(argc, argv);
|
||||
|
||||
for (int i = 0; i < argc - 1; i++) {
|
||||
if (ARGS[i] == "clients")
|
||||
for (std::string arg : ARGS) {
|
||||
if (arg == "clients")
|
||||
clients::clients();
|
||||
}
|
||||
/* for (int i = 1; i < argc; i++) {
|
||||
}
|
||||
|
||||
for (int i = 0; argc > i; i++) {
|
||||
if (argc) {
|
||||
}
|
||||
}*/
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue