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 <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "clients.hpp"
|
#include "clients.hpp"
|
||||||
|
|
||||||
std::string *splitArgs(int argc, char **argv) {
|
std::vector<std::string> splitArgs(int argc, char **argv) {
|
||||||
|
|
||||||
auto result =
|
std::vector<std::string> result;
|
||||||
reinterpret_cast<std::string *>(malloc(sizeof(std::string) * argc));
|
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
result[i - 1] = argv[i];
|
result.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,9 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
const auto ARGS = splitArgs(argc, argv);
|
const auto ARGS = splitArgs(argc, argv);
|
||||||
|
|
||||||
for (int i = 0; i < argc - 1; i++) {
|
for (std::string arg : ARGS) {
|
||||||
if (ARGS[i] == "clients")
|
if (arg == "clients")
|
||||||
clients::clients();
|
clients::clients();
|
||||||
}
|
}
|
||||||
/* for (int i = 1; i < argc; i++) {
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; argc > i; i++) {
|
|
||||||
if (argc) {
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue