Useful Abuse

I found this neat trick:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <string>
#include <vector>

signed main(unsigned, char const *const *args_a)
{
	std::basic_string<char const *> args_s = args_a;
	std::vector<std::string> args_v (std::begin(args_s), std::end(args_s));

	for(auto const &arg : args_v)
	{
		std::cout << "\"" << arg << "\"" << std::endl;
	}
}
I consider it "useful abuse". Clearly I could just use the argc parameter with std::vector directly, but I wanted to have fun.
Did you stumbled upon fact that argv[argc] is always a null pointer and though of this?

Also: signed main, unsigned, char const *const *,
LB wrote:
Abuse
I see what you did here.
Topic archived. No new replies allowed.