51 lines
1.0 KiB
C
51 lines
1.0 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
#include <stdbool.h>
|
|
|
|
#define SIZE 128
|
|
|
|
int main() {
|
|
|
|
struct student {
|
|
char name[SIZE];
|
|
int votes;
|
|
};
|
|
|
|
//pomocne premeny
|
|
struct student databaza[SIZE];
|
|
memset(databaza,0,SIZE*sizeof(struct student));
|
|
int size = 0;
|
|
char meno[SIZE];
|
|
char line[SIZE];
|
|
memset(line,0,SIZE);
|
|
char* r = fgets(line,SIZE,stdin);
|
|
|
|
if (r == NULL)
|
|
{
|
|
printf("Chyba: Zlyhalo nacitavanie vstupu.\n");
|
|
}
|
|
|
|
char name[SIZE];
|
|
memset(name,0,SIZE);
|
|
char* zaciatok_mena = end + 1;
|
|
|
|
|
|
int velkost_mena = strlen(zaciatok_mena) - 1;
|
|
if (velkost_mena > 0){
|
|
memcpy(name,zaciatok_mena,velkost_mena);
|
|
// Na konci je v poli name ulozeny retazec s menom
|
|
// bez konca riadka a s nulou na konci
|
|
}
|
|
else {
|
|
// nepodarilo sa nacitat meno
|
|
}
|
|
|
|
char* end = NULL;
|
|
int value = strtol(line,&end,10);
|
|
if (value == 0){
|
|
// Premena sa nepodarila
|
|
}
|
|
return 0;
|
|
} |