Hi,
I'm begginers in language C a need your help.
This is in my main.c and that printf realy write way to file, but...
After that when i push some key program doesn't work and I dont know why ...
All problem is, I get file.c and I search in #include command and way to external(including) file. And I want to ways in *p_ways[]. It's possible?
This is function load_way
Thx, for all comment!
I'm begginers in language C a need your help.
This is in my main.c and that printf realy write way to file, but...
After that when i push some key program doesn't work and I dont know why ...
All problem is, I get file.c and I search in #include command and way to external(including) file. And I want to ways in *p_ways[]. It's possible?
Code:
char *p_ways[number_stars];
int number_include = load_way(result, number_stars, (&p_ways) );
printf("Way: %s\n",p_ways[0]);
printf("Way: %s\n",p_ways[1]);
This is function load_way
Code:
int load_way(char *source, int hasmark, char **way){
char *p_temp;
char *p_tmp;
char include[] = "#include";
int cnt = 0;
int TRUE = 1;
p_temp = strtok(source, " \r\n\t");
int delka;
while(p_temp != NULL){
if(strcmp(p_temp,include) == 0){
p_temp = strtok(NULL, " \r\n\t");
if(p_temp == NULL){
break;
}
else{
if(p_temp[0] == '\"'){
delka = strlen(p_temp);
delka = delka - 3;
p_tmp = (char *)malloc( sizeof(p_temp) );
int f;
for(f = 0; f <= delka; f++){
p_tmp[f] = p_temp[f+1];
}
p_tmp[f] = '\000';
way[cnt] = p_tmp;
cnt++;
}
}
}
p_temp = strtok(NULL, " \r\n\t");
}
return cnt;
}
Thx, for all comment!