I have a program that parses a text file, and stores it in a pointer array. I have only one problem. I'm trying to store an array of strings in a char ** object, but whenever I assign a value to the char **, I get seg faults.
#include "database.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char **get_values(int recipe_num, char *file) {
int placehold_num=recipe_num;
char *text=parse_recipes(file);
int num_recipes=count_recipes(file);
char **array_strings;
int index=-1;
for (int i=0;*(text+i)!='\0';i++) {
if (*(text+i)=='R' && *(text+i+1)=='e' && *(text+i+6)==':' && (text+i+7)==' ') {
i+=13;
index++;
for (int j=0;*(text+i+j-1)!='\n';j++) {
printf("%c",*(text+i+j));
*(*(array_strings+index)+j)=*(text+i+j);
}
}
}
}
This prints out the char I want from *(text+i+j), but seg faults on the next line. I'm extremely sure it isn't a problem with another function being called, I think it must be something with the way I'm dereferencing array_strings. Any help is greatly appreciated.