title: How to declare char sequence for function (C++)?
body: <p>How to make declaration for function to have char sequence in the result?</p>
  
  <p>I have this now:</p>
  
  <pre><code>#define _MAX_PATH   260    
  char * GetTempFileName(char fileName [_MAX_PATH]);
  </code></pre>
  
  <p>But the result should be in type char [_MAX_PATH]</p>
  
  <hr>
  
  <pre><code>#include &lt;array&gt;
  typedef std::array&lt;char,_MAX_PATH&gt; Path;
  extern class Setts
  {
      char path [_MAX_PATH];
  
  public:
      Setts();~Setts();
      Path getTempFileName(const Path &amp;fileName);
  } setts;
  
  Setts::~Setts(){}
  
  Path Setts::getTempFileName(const Path &amp;fileName) 
  {
      GetCurrentDirectory(_MAX_PATH, path);
      strcat(path, "\\");
      strcat(path, fileName);
      return path;
  }
  </code></pre>
  
  <p>This is what makes problem to me... </p>
  
  <pre><code>error C2143: syntax error : missing ';' before 'Setts::GetTempFileNameA'
  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  error C2556: 'int Setts::GetTempFileNameA(Setts::Path)' : overloaded function differs only by return type from 'Setts::Path Setts::GetTempFileNameA(Setts::Path)'
  </code></pre>
  
  <hr>
  
  <p>Is it really not possible to get the result in char sequence char [_MAX_PATH] ? The problem here is, that when I create new type Path, so all functions of conditions that depends on char [_MAX_PATH] type cause errors in the project.</p>
  
  <hr>
  
  <p>From comments with g-makulik</p>
  
  <blockquote>
    <p>What does mean the path.data() ... data looks like some function, what
    does this do? Is it evaluated after the result of the function is
    saved to path variable?  – user1141649 16 mins ago</p>
  </blockquote>
  
  <p>g-makulik:  </p>
  
  <pre><code>It provides access to the std::array's underlying data (an array of char[260]). You can use it in other places to interface that array as well. – 
  </code></pre>
  
  <hr>
  
  <p>I tried to simplify it because compatibility with the rest of the project:</p>
  
  <pre><code>settings.h:
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  #include &lt;array&gt;
  typedef char Path [_MAX_PATH]; 
  
  extern class Setts
  {
      Path&amp; path;
  
  public:
      Setts();~Setts();
  
      Path&amp; getTempFileName(const Path &amp;fileName);
      bool load();
  
      Path&amp; BasePath;
      Path&amp; ScenPath;
  
      Path&amp; TempPath;
      #define DEL_TEMP_ON_EXIT 1;
  
      Path&amp; logname;
  
      bool intense;
  
  } setts;
  </code></pre>
  
  <p>settings.cpp:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include "settings.h"
  #include &lt;stdio.h&gt;
  
  Setts::~Setts(){}
  
  Path&amp; Setts::getTempFileName(const Path &amp;fileName) 
  {
      GetCurrentDirectory(_MAX_PATH, path);
      strcat(path, "\\");
      strcat(path, fileName);
      return path;
  }
  
  bool Setts::load()
  {
      TempPath = getTempFileName("scendata.tmp");
      logname = getTempFileName("ats_cache.log");
  
      return (result == ERROR_SUCCESS);
  }
  </code></pre>
  
  <p>Now I got error: <code>near TempPath = getTempFileName("scendata.tmp");</code> and <code>logname = getTempFileName("ats_cache.log");</code> :</p>
  
  <p>'Setts::getTempFileName' : cannot convert parameter 1 from 'const char [13]' to 'const Path (&amp;)'
  Reason: <strong>cannot convert from 'const char [13]' to 'const Path'</strong>
  There is no context in which this conversion is possible
  error C2664: 'Setts::getTempFileName' : cannot convert parameter 1 from 'const char [14]' to 'const Path (&amp;)'
  Reason: <strong>cannot convert from 'const char [14]' to 'const Path'</strong>
  There is no context in which this conversion is possible </p>