https://docs.google.com/document/d/1R_rYGMRvzEaBQeMp0OtLd6v3L3-ajliMKf4YOBGnMcE/edit
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
void kiir(int n, int *a);
int main(){
int * input;
// int i;
int i = 1;
int ertek;
int j;
srand(time(NULL));
int x = sizeof(int);
int y = sizeof(int);
input = (int *) malloc(x);
for(j = 0; j < i; j++){
printf("Kerem az erteket: ");
scanf(" %d", &ertek);
if(ertek>0){
input = realloc(input, y);
// input[j] = rand() % 100;
input[j] = ertek;
y = y + x;
i++;
}
}
kiir(i, input);
return 0;
}
void kiir(int n, int *a){
int i;
for(i = 0; i < n; i++){
printf("Az %d. elem: %dn", i , a[i]);
}
}
#include <stdio.h>
#include <stdlib.h>
#include <errno.h> // hibakezel괨ez
#include <dirent.h>
#include <sys/types.h>
#include <string.h>
#include <sys/stat.h>
void konyvtar(char form[], char di[]){
DIR * D;
struct dirent * direntp;
struct stat my_status;
char new_form[80];
char new_form_s[80];
char fname[80];
strcpy(new_form, form);
strcat(new_form, "t ");
strcpy(new_form_s, form);
strcat(new_form_s, "%sn");
chdir(di);
D = opendir(".");
if(!errno){
// könyvtár nyitva, olvassuk
while((direntp=readdir(D))!=NULL){
strcpy(fname, direntp -> d_name);
printf(new_form_s, fname);
if((strcmp(fname, ".")!=0) && (strcmp(fname, "..")!=0)){
stat(fname, &my_status);
if(S_ISDIR(my_status.st_mode)){
strcat(new_form, "t");
konyvtar(new_form, fname);
}
}
}
}
closedir(D);
}
int main(){
char D[80] = ".";
printf("Az aktualis konyvtar tartalma: n");
konyvtar(" ", D);
return 0;
}