/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    FILE *textfile;
    int i;
    int num_of_lines;
    char textline[50];
    char *parr[20];
    textfile = fopen("splitline.txt", "r");
    num_of_lines = 0;
    while(fgets(textline, sizeof(textline), textfile))
    {
        if(textline[strlen(textline)-1] == '\n') textline[strlen(textline)-1] = 0;
        parr[num_of_lines] = malloc(strlen(textline)+1);
        strcpy(parr[num_of_lines], textline);
        num_of_lines++;
    }
    fclose(textfile);
    for(i = 0; i < num_of_lines; i++)
    {
        printf("%s\n", parr[i]);
    }
    return 0;
}
