Commit 58e1803b by edtell

Add new file

parents
Showing with 75 additions and 0 deletions
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char nimi[32];
int kood;
int hinne[4];
} Inim;
void input(FILE *sisse, Inim *);
void print(Inim *, Inim *);
void fnimi(char*, char*);
int loe(FILE *sisse);
int main( void ){
int N = 0;
FILE *sisse;
FILE *valja;
char nimi[128];
fnimi(nimi, "sisestame input faili nimi: ");
sisse=fopen(nimi, "r");
N = loe(sisse);
if(sisse==NULL){
printf("Pole faili\n");
return 1;
}
int k=0;
Inim nimekiri[N];
while(!feof(sisse))
{
input(sisse, &nimekiri[k]);
k++;
}
fclose(sisse);
fnimi(nimi, "sisestame output faili nimi: ");
printf("\n");
valja=fopen(nimi, "r+");
fclose(valja);
return 0;
}
void fnimi(char *nimi, char *tekst){
printf("%s", tekst);
scanf("%s", nimi);
}
int loe(FILE *sisse){
int i = 0;
char buff[59];
int buff2, buff3[4];
while(fscanf(sisse,"%s %d %d,%d,%d,%d", buff, &buff2, &buff3[0], &buff3[1], &buff3[2], &buff3[3]) !=EOF){
i++;
}
rewind(sisse);
return i;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment