jweinst1
10/5/2017 - 7:40 AM

pntparser.cpp

#include <iostream>
#include <cstddef>

//formatting parsing functions via putting values in pointers and returning a bool.

bool countOne(const char* str, double* num, size_t* parsed)
{
  *num = 0;
  for(*parsed = 0; *parsed < 4; (*parsed)++)
  {
    if(*str == '1') { (*num)++; }
    str++;
  }
  return true;
}

int main() {
  double n = 0;
  size_t count = 0;
  if(countOne("1010", &n, &count))
  {
    std::cout << n << "\n";
    std::cout << count << "\n";
    //2 
    //4
  }

}