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 Wczytwanie pliku ( 13 years ago )
#include <stdio.h>
#include <stdlib.h>
int main()
{
//POTRZEBNE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
char ** tab=NULL; int sizeTab=0; //tablica z twoimi tekstami i jej rozmiar
FILE *fp;
char tekst;
if ((fp=fopen("poka.txt", "r"))==NULL) { // poka.txt to ten plik
printf ("Nie mogę otworzyć pliku!\n");
exit(1);
}
rewind (fp);
while(1)
{
char * tekst=malloc(20);
int i =0;
for(; i < 20; i++)
tekst[i]=0;
fscanf(fp, "%s", tekst);
sizeTab++;
tab=(char ** )realloc(tab, sizeof(char**) * sizeTab);
tab[sizeTab-1]=tekst;
if (feof(fp)) {
break;
}
}
fclose(fp);
//POTRZEBNE !!!!!!!!!!!!!!!!!!!!!!!!!!!!
//POKAZUJE ZE DZIALA
int i =0;
for(;i<sizeTab;i++) {
printf("%s\n", tab[i]);
}
//CZYSZCZENIE
for(;i<sizeTab;i++) {
free(tab[i]);
}
free(tab);
/////////////////
scanf("%d*");
return 0;
}
Revise this Paste