Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int dictionary_lang_list(char **list, size_t *list_len){
- char *path;
- path=malloc(256*sizeof(char));
- path[0]='\0';
- strcat(path, CONF_PATH);
- strcat(path,"/");
- strcat(path, ".lang_list");
- *list =NULL;
- FILE *fp;
- fp=fopen(path,"r");
- char c;
- char buffer[256];
- size_t i=0, j=0, akt=0;
- bool empty=true;
- list_len =0;
- char **pom=*list;
- while((c=fgetc(fp))!=EOF){
- // fprintf(stderr, "%c ", c);
- if(c!='\n'){
- buffer[i]=c;
- i++;
- empty=false;
- }else {
- buffer[i] ='\0';
- *list=realloc(*list,(akt+i+1)*sizeof(char));
- //for(j=0;j<=i;++j){
- *(list)=strcpy(*list, buffer);
- //}
- akt+=i+1;
- pom+=i;
- i=0;
- if(!empty) {
- *list_len++;
- fprintf(stderr, "zwiekszam\n");
- }
- }
- }
- free(path);
- fclose(fp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement