title: Copy 2d Character Array inAanother 2d Array Using STRCPY
body: <p>I am trying to copy a 2d character array into another 2d character array using the string function strcpy but it's giving me the error of access violation. I don't know what is it that I am doing wrong. I am posting the code and error can somebody tell me what is it that I am doing wrong </p>
  
  <pre><code>int searching(char *name[],char * namesearched,int size)
  {
      int count =0;
      int start = 0;
      int end = count;
      for(;start&lt;=end;)
      {
          int mid = (start + end)/2;
          if(strcmp(namesearched,name[mid])==0)
          {
          return mid;
          }
          else if(strcmp(namesearched,name[mid])==1)
          {
           end=mid -1; 
          }
          else if(strcmp(namesearched,name[mid])==-1)
          {
  
              start = mid +1;
          }
      }
      return -1;
  }
  
  void sorting(char **name,char ** meaning,int count)
  {
      for (int i=0;i&lt;count;i++)
      {
          for(int j=i+1; j&lt;count; j++)
          {
              char tempname[100];
              char tempmeaning[100];
              if(strcmp(name[j-1],name[j])&gt;0)
              {
                  strcpy(tempname,name[j]);
                  //strcpy(name[j],tempname);
                  strcpy(name[j-1],name[j]);
                  strcpy(name[j],name[j-1]);
                  strcpy(name[j-1],tempname);
  
                  strcpy(tempmeaning,meaning[j]);
                  strcpy(meaning[j],meaning[j-1]);
                  strcpy(meaning[j-1], tempmeaning);
              }
          }
      }
  }
  
  void main()
  {
      int size=60;
      int count=0;
      char namesearched[100];
      cout &lt;&lt; "Enter the name to be searched: ";
      cin.getline(namesearched , 100);
      char** name= new char * [size];
      char** meaning = new char * [size];
      for(int i=0;i &lt; size ; i++)
      {
          name[i]= new char [100];
          meaning[i]= new char[100];
          count ++;
      }
      name[0] = "Journalist";
      name[1] = "Blister";
      name[2] = "List";
      name[3] = "Listen";
      name[4] = "Novelist";
      name[5] = "Song";
      name[6] = "Eat";
      name[7] = "West";
      name[8] = "Idealist";
      name[9] = "Industry";
      name[10] = "Legalist";
      name[11] = "Write";
      name[12] = "Medal";
      name[13] = "Nation";
      name[14] = "Accident";
      name[15] = "Nest";
      name[16] = "Bird";
      name[17] = "Animal";
      name[18] = "Lion";//wrong
      name[19] = "Pigeon";
      name[20] = "Real";
      name[21] = "Accept";
      name[22] = "Ability";
      name[23] = "Bald";
      name[24] = "Backbite";
      name[25] = "Wakeful";
      name[26] = "Absolute";
      name[27] = "Wail";
      name[28] = "Abiding";
      name[29] = "Unacceptable";
      name[30] = "Tacker";
      name[31] = "Vain";//wrong
      name[32] = "Abolish";
      name[33] = "Taking";
      name[34] = "Unarmed";
      name[35] = "Habit";
      name[36] = "Notus";
      name[37] = "Impecle";
      name[38] = "Accelerate";
      name[39] = "Agony";
      name[40] = "Sulk";
      name[41] = "Nowise";
      name[42] = "Hypocrisy";
      name[43] = "Nape";
      name[44] = "Eccentric";
      name[45] = "Naturally";
      name[46] = "Gratitude";
      name[47] = "Mesmerizing";
      name[48] = "Epic";
      name[49] = "Abstain";
      name[50] = "Enactment";
      name[51] = "Hammock";
      name[52] = "Nodal";
      name[53] = "Laborious";
      name[54] = "Nonverbal";
      name[55] = "Haggle";
      name[56] = "Notorious";
      name[57] = "Lagger";
      name[58] = "Pathetic";
      name[59] = "Norms";
  
  
      meaning[0] = "Sahaafi";
      meaning[1] = "Chaala";
      meaning[2] = "Fehrist";
      meaning[3] = "Sunna";
      meaning[4] = "Naval Nigaar";
      meaning[5] = "Ganna";
      meaning[6] = "Khanna";
      meaning[7] = "Maghrib";
      meaning[8] = "Tadawuri";
      meaning[9] = "Sannat";
      meaning[10] = "Zabta Parast";
      meaning[11] = "Likhna";
      meaning[12] = "Tangha";
      meaning[13] = "Qoom";
      meaning[14] = "Hadsa";
      meaning[15] = "Ghonsla";
      meaning[16] = "Parinda";
      meaning[17] = "Janwar";
      meaning[18] = "Shair";
      meaning[19] = "Kabootar";
      meaning[20] = "Haqeekat";
      meaning[21] = "Qabool";
      meaning[22] = "Kabliyat";
      meaning[23] = "Ganja";
      meaning[24] = "Ghebat Karna";
      meaning[25] = "Jagta";
      meaning[26] = "Bikul";
      meaning[27] = "Gham Karna";
      meaning[28] = "Mustakil";
      meaning[29] = "NaGawar";
      meaning[30] = "Jorna Wala";
      meaning[31] = "Gari";
      meaning[32] = "Rad kar dena";
      meaning[33] = "Dil-chasp";
      meaning[34] = "Nehatta";
      meaning[35] = "Addat";
      meaning[36] = "Dakni hawwa";
      meaning[37] = "Rokna";
      meaning[38] = "Taiz karna";
      meaning[39] = "Sakht Takleef";
      meaning[40] = "Roth Jana";
      meaning[41] = "Hargiz Nahi";
      meaning[42] = "Naffaq";
      meaning[43] = "Mankaa";
      meaning[44] = "Sanki";
      meaning[45] = "Fitratan";
      meaning[46] = "Tashakur";
      meaning[47] = "Mashoor Karna";
      meaning[48] = "Razmiya";
      meaning[49] = "Baaz Rakhna";
      meaning[50] = "Nifaaz";
      meaning[51] = "Jholay ki tarhan ka Bichona";
      meaning[52] = "Gutheela";
      meaning[53] = "Mehnat Talab";
      meaning[54] = "Ghair Lafzey";
      meaning[55] = "Takrar Karna";
      meaning[56] = "Badnam";
      meaning[57] = "Ahista Chalnay walla";
      meaning[58] = "Intehai afsoos naak baat";
      meaning[59] = "Mayar";
  
      int mid;
      sorting( name , meaning , count);
      int mid = searching(name,namesearched,count); 
      if( mid == -1 )
      {
          char ** tempname = new char* [60];
          char ** tempmeaning = new char*[60];
          if(count == size)
          {
              int increase =(10 * size)/100;
              size = increase + size;
              for(int i=0 ; i&lt;size ; i++)
              {
                  tempname[i] = new char [100];
                  tempmeaning[i]= new char [100];
              }
              for(int i = 0; i&lt;count ; i++)
              {                
                  strcpy(tempname[i],name[i]);
                  strcpy(tempmeaning[i],meaning[i]);
              }
          }
          strcpy(tempname[count] , namesearched);
          cin &gt;&gt; tempmeaning[count];
          count ++;
  
          sorting( tempname , tempmeaning , count);
  
          for (int i =0;i &lt; count ;i++)
          {
              delete [] name[i];
              delete [] meaning[i];
          }
          //delete [] name;
          //delete [] meaning;
          name = tempmeaning;
          meaning = tempmeaning;
          tempmeaning = NULL ;
          tempname = NULL;
      }
      else 
      {
          cout &lt;&lt;"The meaning of " &lt;&lt; namesearched &lt;&lt; " is: " &lt;&lt; meaning[mid] &lt;&lt; endl;
      }
      _getch();
  }
  </code></pre>
  
  <blockquote>
    <p>Access violation writing location 0x001fbe5c.</p>
  </blockquote>
  
  <p>The value of <strong>count</strong> and <strong>size</strong> is 60</p>
  
  <p>One thing more strcpy works on this line <code>strcpy(tempname , name[j])</code> but when it encounter this line <code>strcpy(name[j] , name[j-1])</code> it throws me the error of access violation</p>