i'm right now using C, IO is done via ncurses, but that won't affect the following problem, i think.
The relevant code is:
-----
Expand|Select|Wrap|Line Numbers
- #define SIDEBARWIDTH 27
- //...
- typedef struct {
- char line[SIDEBARWIDTH];
- int hotkey;
- void (*todo)(int);
- } _MENULINE;
- //...
- char line[SIDEBARWIDTH];
- strcpy(line,"Feld auswaehlen (ENTER)");
- _MENULINE *newline;
- newline = malloc(sizeof(newline));
- strcpy(newline->line,line);
- mvwprintw(infowin.win,0,0,"%s",newline->line);
- mvwprintw(infowin.win,1,0,"%s",line);
For unknown reason those 2 outputlines are not the same. It gives:
Feld auswaeh!^K
Feld auswaehlen (ENTER)
Changing Sidewarwidth to some bigger value won't help that. (actually the string is 26 chars itself, so fits with 27)
Typecasting the mallocoutput doesn't do anything.
Also if i copy charwise via
Expand|Select|Wrap|Line Numbers
- for (int i=0;i<SIDEBARWIDTH;i++)
- newline->line[i]=line[i];
What's going wrong here? malloc allocating somehow wrong? And how could it be fixed?
edited:
i now tried some more if add those lines in the end
Expand|Select|Wrap|Line Numbers
- strcpy(line,newline->line);
- mvwprintw(infowin.win,2,0,"%s",line);
Not sure if that might be ncurses fault. Still feels odd.