Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct el{
- int x;
- struct el *next;
- }*start, *tmp, *p,*g1;
- void push(int x);
- void izpis();
- void izbris(int b);
- int main(int argc, char *argv[])
- {
- FILE *pFile = fopen("text.txt","r");
- int x,l;
- while((x=getc(pFile))!=EOF)
- {
- push(x);
- }
- izpis();
- fclose(pFile);
- printf("\n");
- printf("mesto izbrisa");
- scanf("%d",&l);
- izbris(l);
- izpis();
- system("PAUSE > NULL");
- return 0;
- }
- void push(int x)
- {
- tmp = (struct el*)malloc(sizeof(struct el));
- tmp->x = x;
- tmp->next = start;
- start = tmp;
- }
- void izpis()
- {
- p = start;
- while(p != NULL)
- {
- printf("%c",p->x);
- p = p->next;
- }
- }
- void izbris(int b)
- {
- int i,l;
- l = b;
- tmp = NULL;
- g1 = start;
- for(i=1;i<l;i++)
- {
- g1=g1->next;
- }
- tmp = g1;
- g1 = tmp->next;
- free(tmp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement