D
dachteruit
Hi all,
First of all I'm a newbie in C programming and I was playing around
with ncurses.
I've followed the instructions as described in
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/misc.html#TEMPLEAVE to
leave curses mode temporarily. So I wrote the following:
#include <stdio.h>
#include <ncurses.h>
#include <string.h>
int main(){
int i=0, j=2560;
char last, result[j];
initscr();
cbreak();
refresh();
do {
last = getch();
def_prog_mode();
endwin();
strcat(last, result);
printf("Last one is: %c\n", last); //doesn't work
printw("The very last one is: %c\n", last); //printw does still
work!!!
reset_prog_mode();
refresh();
}while(last != 's');
for(j=0;j<2560;j++) printw("%c", result[j]);
refresh();
getch();
endwin();
return 0;
}
Can anyone explain me why printw works and printf don't when I'm
temporarily out of curses mode?
In addition you may explain too why the for-loop returns a scrambled
output, but that's not yet my main problem.
Thanks,
Nico
First of all I'm a newbie in C programming and I was playing around
with ncurses.
I've followed the instructions as described in
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/misc.html#TEMPLEAVE to
leave curses mode temporarily. So I wrote the following:
#include <stdio.h>
#include <ncurses.h>
#include <string.h>
int main(){
int i=0, j=2560;
char last, result[j];
initscr();
cbreak();
refresh();
do {
last = getch();
def_prog_mode();
endwin();
strcat(last, result);
printf("Last one is: %c\n", last); //doesn't work
printw("The very last one is: %c\n", last); //printw does still
work!!!
reset_prog_mode();
refresh();
}while(last != 's');
for(j=0;j<2560;j++) printw("%c", result[j]);
refresh();
getch();
endwin();
return 0;
}
Can anyone explain me why printw works and printf don't when I'm
temporarily out of curses mode?
In addition you may explain too why the for-loop returns a scrambled
output, but that's not yet my main problem.
Thanks,
Nico