SHARE
TWEET

Untitled

a guest Apr 19th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. #define MAX_DM_COUNT 7
  6.  
  7. typedef struct {
  8.   char* name;
  9.   char* path;
  10. } DM;
  11.  
  12. void read_into(DM **dm_array, FILE *file) {
  13.   int i;
  14.   for(i = 0; i < MAX_DM_COUNT; ++i) {
  15.     char* name = malloc(sizeof(char*));
  16.     char* path = malloc(sizeof(char*));
  17.  
  18.     fscanf(file,"%s : %s",name, path);
  19.     printf("Name:%s Path:%s",name,path);
  20.  
  21.     free(name);
  22.     free(path);
  23.   }
  24. }
  25.  
  26. int main() {
  27.     FILE *file;
  28.     printf("Please don't segfault");
  29.     DM **dm_array = malloc (MAX_DM_COUNT * sizeof(DM*));
  30.     file = fopen("~/.config/dman/display-managers.txt", "r");
  31.     read_into(dm_array, file);
  32.     return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top