title: How do i fix this error "was not declared in this scope"
body: <p>System is:  Linux/CentOS 6.4</p>
  
  <p>I keep getting an error for functions not declared in scope. Is it not legal to call a function within another function? I read an article on function, thought it was because I needed to declare the functions void when I call them, but I received new errors. Not sure if I need to declare them global or something.</p>
  
  <blockquote>
    <p>client.cpp:32: error: 'takef' was not declared in this scope</p>
    
    <p>client.cpp:33: error: 'putf' was not declared in this scope</p>
    
    <p>client.cpp: In function 'void takef(int&amp;)': </p>
    
    <p>client.cpp:44: error: 'testa'  was not declared in this scope</p>
    
    <p>client.cpp: In function 'void putf(int&amp;)':</p>
    
    <p>client.cpp:70: error: 'test' was not declared in this scope</p>
  </blockquote>
  
  <p>example of type of code I'm trying to implement</p>
  
  <pre><code>sem_t mutex;
  sem_t S;
  char buffer[1024];
  void error(const char *msg)
  {
      perror(msg);
      exit(0);
  }
  /*void signal_callback_handler()
      {
          close(sockfd);
  
      }*/
  
  
      void father(int &amp;sockfd)
      {
          while(1)
          {
              srand(time(NULL));
              int ms= rand() % 2000 + 5000
              send(sockfd, DATA, strlen(DATA), 0);
              usleep(1000*ms);
              takef(sockfd);
              putf(sockfd);
          }
  
      }
  
      void takef(int &amp;sockfd)
      {
  
      *
      *
      *  *Other code*
      *
      *
      *
          testa(sockfd);
  
      *  *Other code*
      *
      *
      *
      }
  
  
      void testa(int &amp;sockfd)
      {
      *
      *
      *
      *  *Other code*
      *
      *
      *
  
      }
  
      void putf(&amp;sockfd)
      {
      *
      *
      *
      *  *Other code*
      *
      *
      *
      test();
      test();
      sem_post(&amp;mutex);
  
     }
  
  int main(int argc, char *argv[])
  {
      *
      *
      *
      *  *Other code*
      *
      *
      *
      father(sockfd);
  
      return 0;
  
  }
  </code></pre>