I have an API function that takes constant char * as an input. I have to create a delimited text file which is the input of the function like:
193.875 0.0 0.0 2
193.876 0.0 0.0 2
193.877 0.0 0.0 2
193.878 0.0 0.0 2
193.879 0.0 0.0 2
193.880 0.0 0.0 2
193.881 0.0 0.0 2
the support guy of the software told me that I can create and save every line of this file by using sprintf() so I used it like:
sprintf(wsp,"%.3f\t0.0\t0.0\t%d\n", start_freq, z);
and after putting this line in loop I saved every created wsp in an array of string:
for (int j = 0; j < start; j++){
sprintf(wsp,"%.3f\t0.0\t0.0\t%d\n", start_freq, z);
start_freq = start_freq + 0.001;
wspfile[j] = wsp;
}
now I have a file with the required format but comes in array of string. My question is after creating the array how can I pass this array as a constant char * or how can I convert it to constant char *
You could make wspFile an std::string instead of an array. Then instead of
you would have
Then to get the const char* version you would call