2
I am creating a function that receives and breaks a string into several, depending on the delimiter(s) chosen by the programmer. So I have:
void split(const wchar_t* text, const wchar_t* seps,wchar_t ***str, int *count)
- text: the string to be broken
- seps: the delimitators
- str: string array (return)
- Count: number of broken strings
The function seems to work without any problem and no memory Leak. The problem is that when using the text output function (in the X11 window), it appears with random colors. I’ve erased the entire body of the function, but the problem still persists.
The code is like this:
void split(const wchar_t* text, const wchar_t* seps,wchar_t ***str, int *count){
//nota que o corpo da função está vazio
}
void ShowWindow(const char* title, const wchar_t* text)
{
Display* dpy = NULL;
Window win;
wchar_t** text_splitted;
int textLines;
setlocale(LC_ALL,"");
split(text,L"\n" , &text_splitted, &textLines);
...
}
It is something very strange, because the function is empty. And when I do not call it, the text appears with the black color, which is the normal.
Note: Colors do not appear when compilation the code on Ubuntu, but when compilation in Debian appear.
Not a X11 problem? How are you printing, on output? It can be a TTY type configuration with ANSI
– Marcelo Shiniti Uchimura
I have no idea if X11 is a problem or not. Check this out https://pasteboard.co/HocpngM.png
– user72726
You also comment on the code to debug the result?
for(i = 0; i < textLines; i++) { wprintf(L"%ls\n", text_splitted[i]); } fflush(stdout);
?– Marcelo Shiniti Uchimura
Yes. I just forgot to add in gist too.
– user72726
These graphics capable terminals support color escapement characters, screen positioning, sparkling (flashing) characters... Could be, at some point in the code, some character like this is coming out.
– Marcelo Shiniti Uchimura
I already managed to solve the problem. I was declaring the variables in the middle of the function
ShowWindow
. Inc
variables must be declared at the beginning of a code block. (at least I think that was it)– user72726
its problem is not to pass variables without initializing and not where they were declared?
– Ricardo Pontual
It is not that. Even because the body of the function is empty.
– user72726