title: c++ error identifier not found for function?
body: <p>this is my first steps in C++ , and I'm trying to run a function I need to use </p>
  
  <p>but I get this error :</p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State
    Error C3861   'findAndRotateBlankNumbers': identifier not
    found ConsoleApplication2 c:\users\source\repos\consoleapplication2\consoleapplication2\consoleapplication2.cpp   29</p>
  </blockquote>
  
  <p>and this is the code:</p>
  
  <p>// ConsoleApplication2.cpp : Defines the entry point for the console application.
  //</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  
  enum States {
      needBlank,
      needNumber,
      collectNumbers,
  };
  
  bool finish = false;
  int i = 0;
  
  int main()
  
  {
  
  
      char data[] = { "they're 2fast 96 345 6789 a11 24x 2424" };
  
  
      printf(data);
      findAndRotateBlankNumbers(data);
      printf(data);
  
      system("pause");
  
  
  
  
  
      return 0;
  }
  
  
  void findAndRotateBlankNumbers(char* ptr) {
      char* first;
      char* last;
      for (uint8_t state = needBlank; *ptr; ptr++) {
          switch (state) {
          case needBlank:
              if (*ptr == ' ') {
                  state = needNumber;
              }
              break;
          case needNumber:
              if (isdigit(*ptr)) {
                  state = collectNumbers;
                  first = ptr;
              }
              else if (*ptr != ' ') {
                  state = needBlank;
              }
              break;
          case collectNumbers:
          {
              bool swap = false;
              if (!isdigit(*ptr)) {
                  last = ptr - 1;
                  state = (*ptr == ' ' ? needNumber : needBlank);
                  swap = true;
              }
              else if (!ptr[1]) {
                  last = ptr;
                  swap = true;
              }
              if (swap) {
                  if (last != first) {
                      for (int8_t nums = (last - first + 1) / 2; nums--; ) {
                          char swap = *first;
                          *first++ = *last;
                          *last-- = swap;
                      }
                  }
              }
              break;
          }
          }
      }
  
  }
  </code></pre>
  
  <p>what is this ?</p>
  
  <hr>
  
  <p>I have change the order of the code to like you suggested :</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  
  enum States {
      needBlank,
      needNumber,
      collectNumbers,
  };
  
  bool finish = false;
  int i = 0;
  
  void findAndRotateBlankNumbers(char* ptr) {
      char* first;
      char* last;
      for (uint8_t state = needBlank; *ptr; ptr++) {
          switch (state) {
          case needBlank:
              if (*ptr == ' ') {
                  state = needNumber;
              }
              break;
          case needNumber:
              if (isdigit(*ptr)) {
                  state = collectNumbers;
                  first = ptr;
              }
              else if (*ptr != ' ') {
                  state = needBlank;
              }
              break;
          case collectNumbers:
          {
              bool swap = false;
              if (!isdigit(*ptr)) {
                  last = ptr - 1;
                  state = (*ptr == ' ' ? needNumber : needBlank);
                  swap = true;
              }
              else if (!ptr[1]) {
                  last = ptr;
                  swap = true;
              }
              if (swap) {
                  if (last != first) {
                      for (int8_t nums = (last - first + 1) / 2; nums--; ) {
                          char swap = *first;
                          *first++ = *last;
                          *last-- = swap;
                      }
                  }
              }
              break;
          }
          }
      }
  
  }
  
  int main()
  
  {
  
  
      char data[] = { "they're 2fast 96 345 6789 a11 24x 2424" };
  
  
      printf(data);
      findAndRotateBlankNumbers(data);
      printf(data);
  
      system("pause");
  
  
  
  
  
      return 0;
  }
  </code></pre>
  
  <p>but now I get other errors:</p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State
    Error C4703   potentially uninitialized local pointer variable 'first'
    used  ConsoleApplication2 c:\users\source\repos\consoleapplication2\consoleapplication2\consoleapplication2.cpp  52</p>
  </blockquote>
  
  <p>?</p>