#include #include static FILE * fptr; char * readline(char * fname, int lnr) { char * buff; char * line = NULL; int i, h = 1, g = 0; fptr =fopen(fname, "r"); line = malloc(sizeof(char)*48); if (fptr ==NULL) { return NULL; } fread(buff, 19200, 4, fptr); for (i = 0; i < 480; i++) { printf("wir sind jetzt bei zeichen %i, dies ist ein %c \n", i+1, buff[i]); if (* buff == '\n') { h++; printf("zeilenwechsel. \n"); } else { if (lnr == h) { line = buff; printf("%c \n", *line); g++; } if (lnr == h - 1 && g != 0) { *line = '\0'; printf("string abgeschlossen. \n"); printf("letztes zeichen der Zeile: %c \n", *(line -1) ); return line; } if (lnr == h -1 && g == 0) { return NULL; } } buff++; } return line; } int writeline(char * fname, int lnr, char * str) { fptr = fopen(fname, "r+"); if (fptr ==NULL) { return 1; } fprintf(fptr, str); fclose(fptr); return 0; } int deleteline(char * fname, int lnr) { return 0; } int main(void) { char * teststring; teststring = malloc(sizeof(char)*48); teststring = readline("test.db", 1); // if (teststring == NULL) // printf("null pointer! \n"); // else // printf("was anderes"); return 0; }