Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.  
  6. int main()
  7. {
  8.     char ** word = malloc(sizeof(char *) * 5); // here is my problem
  9.  
  10.     int i=0;
  11.  
  12.     for (i=0;i<10;i++)
  13.     {
  14.         word[i]=malloc(sizeof(char)*100);
  15.         sprintf(word[i],"this_%d",i);
  16.     }
  17.  
  18.  
  19.     for (i=0;i<10;i++)
  20.     {
  21.         printf("%s  %p\n",word[i],word[i]);
  22.     }
  23.  
  24.  
  25.     for (i=0;i<10;i++)
  26.     {
  27.         if (strcmp(word[i],"this_4")==0) printf("yes found\n");
  28.     }
  29.  
  30.  
  31.     i=0;
  32.     for (i=0;i<10;i++)
  33.     {
  34.         printf("%s %p %p\n",word[i],word[i],&word[i]);
  35.        
  36.    
  37.     }
  38.    
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement