All pastes #57332 Raw Edit

Unnamed

public text v1 · immutable
#57332 ·published 2006-05-20 19:03 UTC
rendered paste body
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define N 128
#define M 3

void get_data_from_user() {
  FILE *fp;
  char epitheto[N];
  char onoma[N];
  float grade;
  int i;

  fp = fopen("eisagwgi.txt", "w");
  if (fp == NULL) {
    fprintf(stderr, "Error opening file for input.\n");
    exit(1);
  }

  printf("Dwse to epitheto: ");
  scanf("%s", &epitheto);

  while (strcmp(epitheto, "*")) {
    fprintf(fp, "%s", epitheto);

    printf("Dwse onoma: ");
    scanf("%s", &onoma);
    fprintf(fp, "%s ", onoma);

    for (i=0; i<M; i++) {
      printf("Dwse thn %di vathmologia: ", i+1);
      scanf("%f", &grade);
      fprintf(fp, "%f ", grade);
    }

    fprintf(fp, "\n");
    printf("Dwse to epitheto: ");
    scanf("%s", &epitheto);
  }

  fclose(fp);
}


int main() {
  get_data_from_user();
  
  return 0;
}