Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #define MAX_DM_COUNT 7
- typedef struct {
- char* name;
- char* path;
- } DM;
- void read_into(DM **dm_array, FILE *file) {
- int i;
- for(i = 0; i < MAX_DM_COUNT; ++i) {
- char* name = malloc(sizeof(char*));
- char* path = malloc(sizeof(char*));
- fscanf(file,"%s : %s",name, path);
- printf("Name:%s Path:%s",name,path);
- free(name);
- free(path);
- }
- }
- int main() {
- FILE *file;
- printf("Please don't segfault");
- DM **dm_array = malloc (MAX_DM_COUNT * sizeof(DM*));
- file = fopen("~/.config/dman/display-managers.txt", "r");
- read_into(dm_array, file);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement