/*
Nome: Mario
Cognome: Montanari

strncpy()
*/

#include <iostream>
#include <cstring>

#define SIZE 100+1

using namespace std;

char *strncpy(char *dst, const char *src, int n);

int main(void) {
	char src[SIZE] = "mario.montanari@studenti.itisravenna.it";
	char dst[SIZE];
	char *ptr;
	
	ptr = strncpy(dst, src, 15);
	
	cout << src << endl;
	cout << ptr << endl;
	
	return 0;
}

char *strncpy(char *dst, const char *src, int n) {
	const char *ptr = dst;
	
	while (n > 0 && *src) {
		*dst = *src;
		dst++;
		src++;
		n--;
	}
	
	while (n > 0) {
		*dst = '\0';
		dst++;
		n--;
	}
	
	*dst = '\0';
	
	return (char*)ptr;
}