#include <stdio.h>
#include "IdanStringPointersLib.h"

#define STRING_MAX_SIZE 256


int LenghtString(char *ptrStr)
{
	char *ptrEndStr = LastCharOfString(ptrStr);
	int DifferenceStr = (ptrEndStr - ptrStr);
	return (DifferenceStr);
}

void Revers(char * ptrStr)
{
	//puts(ptrStr);
	char * ptrEnd = LastCharOfString(ptrStr);
	int length = ZERO;
	while (ptrEnd > ptrStr)
	{
		Swap(ptrStr++, ptrEnd--);
		length++;
	}
	*(ptrStr + length ) = ZERO;
	ptrStr -= length + ONE;
	
}

void Itoa(int num , char *ptrStr, unsigned short base)
{
	char sign ;
	int diff;
	int length =ZERO;
	while (num > ZERO)
	{
		sign = '0';
		diff = num % base;
		sign += (diff > TEN) ? SEVEN + diff : diff;
		*(ptrStr++) = sign;
		num /= base;
		length++;
	}
	*ptrStr = ZERO;
	ptrStr -= length + ONE;
	Revers(ptrStr);	
}

//-----------------------------------------------------------------
//								exe 4
//                              -----
// General : the program turns a num into string.
//
// Input   : num and base.
//
// Process : the program takes each number and adds the value in
//           computer code of '0' to it, to turn it to a char.
//
// Output  : the num as a string.
//
//-----------------------------------------------------------------
// Proggramer : Cohen Idan 
// Student No : 211675038
// Date : 12.11.19
//-----------------------------------------------------------------
void main(void)
{
    char stringA[STRING_MAX_SIZE] = "aaaaaaaaaaaababbbbbbbbbab";
    char stringB[STRING_MAX_SIZE] = "ab";
    printf("Count: %d\n", CountStringBInStringA(&stringA[ZERO], &stringB[ZERO]));

}