I'm working in c++, so I started to make a system that open a sentence in a 2d array of chars. After I trying hard to solve problems with it, I got it working, but not in the way it was supposed.
#include <iostream>
#include <cstring>
using namespace std;
void backword(char* input, char* output[])
{
for(int i = 0, c = 0; strlen(input)>i; i++)
{
if(input[i] == ' ')
{
c++;
i++;
}
output[c] += input[i];
}
cout << output[1]; //debug
}
int main()
{
char** output = new char*[30];
backword("dfs sdfsdfsd dsffsdf", output);
cout << output[1]; //dubug
return 0;
}
So whats the issue?: It don't show anything, after my debug it seems my array is not changed
More details:This code I tried in visual studio, not working, tried in Code::Blocks, same result. Initially was intended to return a pointer char**, but I started with this method, and I didn't got any compile errors.
P.S:Sorry if it's a dumb mistake, but I didn't work with chars in this way before.
Thank you.