ncurses' printw() doesn't work
i filled a matrix with strings from a file, that printf() see correctly,
but printw() doesn't seem to agree with the rest of the code. it works
with normal strings, but with strings from that matrix, it doesn't work.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ncurses.h>
int main (int argc, char const *argv[])
{
    char** matrice = malloc(sizeof(char*)*51);
    size_t nbytes;
    int i = 0, j = 0;
    FILE* lab = fopen(argv[1], "r");
    while((getline(&matrice[i], &nbytes, lab) != -1))
    {
        i++;
    }
    printf("%s", matrice[0]);
    getchar();
    initscr();          /* Start curses mode        */
    cbreak();           /* Line buffering disabled  */
    keypad(stdscr, TRUE);       /* We get F1, F2 etc..      */
    noecho();           /* Don't echo() while we do getch */
    printw(matrice[0]);
    printw("dummy line"\n);
    refresh();
    getch();
    endwin();
    return EXIT_SUCCESS;
}
 
No comments:
Post a Comment