Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with pointers

Status
Not open for further replies.

Omnider

Programmer
Joined
Nov 12, 2011
Messages
2
Location
CZ
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?


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!
 
Ohhhh, I'm sorry this question was to language C.... I'm so sorry!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top