Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C by wasyl ( 14 years ago )
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
char *data;
struct node *next;
} row;
void wypisz(row *lista){
row *wsk = lista;
while (wsk!= NULL){
printf("%s\n", wsk->data);
wsk = wsk->next;
}
}
void dopisz(char *tekst, row *lista){
row *wsk = lista;
while (wsk->next != NULL){
wsk = wsk->next;
}
row *nowy;
nowy = malloc(sizeof(row));
nowy->data = malloc(sizeof(tekst));
nowy->data = tekst;
nowy->next = NULL;
wsk->next = nowy;
int main(void){
const char file[] = "file.txt";
FILE *fp;
fp = fopen(file, "r");
row *first;
first = malloc(sizeof(row));
first->data = "test";
first->next = NULL;
char line[200];
while(fgets(line, sizeof line, fp))
{
dopisz(line, first);
}
fclose(fp);
wypisz(first);
return 0;
}
Revise this Paste
Children: 43501