Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- //#include "utils.h"
- enum entry_type_t { FLOAT, INTEGER};
- enum direction_t {ASC, DESC};
- struct item_t
- {
- enum entry_type_t type;
- union
- {
- int i;
- float f;
- };
- };
- struct array_t
- {
- int size;
- struct item_t data[100];
- };
- int read_file(const char* fname, struct array_t *arr)
- {
- if(!fname || !arr) return 1;
- FILE *file1;
- file1=fopen(fname, "r");
- if(!file1) return 2;
- enum entry_type_t type;
- /*char T[4], *tab=T;
- tab=(char *) malloc (sizeof(char)*4);*/
- char tab[3];
- float x;
- int i=0, y;
- fscanf(file1, "%s", tab);
- if(tab=="INT")
- {
- fscanf(file1, "%d", &y);
- type=INTEGER;
- arr->data->i=y;
- }
- if(tab=="FLO")
- {
- fscanf(file1, "%f", &x);
- type=FLOAT;
- arr->*(data+i).
- }
- //fscanf(file1, "%s", tab3);
- //printf("%s\n %d\n %s\n ", tab, y, tab3);
- printf("%s\n%d\n", tab, y);
- return 0;
- }
- int main()
- {
- struct array_t *x;
- x=(struct array_t *) malloc (sizeof(struct array_t));
- read_file("input.txt", x);
- /*float a=12.5;
- int b=1;
- b=a;
- printf("%d", b);*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement