Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct list {
- char *string;
- struct list *next;
- };
- typedef struct list LIST;
- int main(void) {
- FILE *fp;
- char line[63];
- LIST *current, *head;
- head = current = NULL;
- fp = fopen("dzimta.text", "r");
- while(fgets(line, sizeof(line), fp))
- {
- if(line[0] != "\n"){
- }else {continue;}
- LIST *node = malloc(sizeof(LIST));
- node->string = strdup(line);
- node->next =NULL;
- if(head == NULL){
- current = head = node;
- } else {
- current = current->next = node;
- }
- }
- fclose(fp);
- for(current = head; current ; current=current->next){
- printf("%s", current->string);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement