#include <stdio.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <string.h>
#include <malloc.h>
/// <summary>
/// Adds strings to a vector
/// </summary>
void GetStrings(std::vector<std::string>& v){
v.push_back("Hi");
v.push_back("There");
v.push_back("Pal");
}
struct s_def {
char** chars;
};
/// <summary>
/// Returns an array of character arrays (C strings)
/// and the array's length, but with an error
/// </summary>
void GetStringsAgain(char *** strings, int & size){
std::vector<std::string> sts;
GetStrings(sts);
size = sts.size();
*strings = ((char**)(&sts[0]));
}
int main()
{
// define the out parameters
int size = 0;
char** strs = NULL;
// Get the strings
GetStringsAgain(&strs, size);
// Inspect the out parameters
printf("size = %d\n", size);
for (int n = 0; n < size; n++){
printf("%s\n", *strs);
strs++;
}
return 0;
}