All pastes #350818 Raw Edit

zzzz

public text v1 · immutable
·published 2007-02-11 19:14 UTC
rendered paste body
#include <stdio.h> 
#define Max 20
int dupliqueMot (char* ,char* ,int);
int main (void)
{
	char tab_mot[Max], tab_taille[Max];
	int longueur,bool;
	printf("Veuillez entrez votre mot : \n");

    	fgets(tab_mot, Max, stdin);
	printf("Veuillez entrez un entier inferieur a 20 pour dupliquer le mot : \n");
	scanf("%d",&longueur);
	bool=dupliqueMot(tab_mot,tab_taille,longueur);
	if (bool==1)
		printf("Votre nouveau mot est cree : %s \n",tab_taille);
	else	
	{
		printf("Erreur, la chaine ne peut etre recopie car elle est trop longue \n");
	}
	return 0;
}
	
	
int dupliqueMot (char tab_mot[],char tab_taille[], int longueur)
{
	int i=0,j=0,k=0,l=0,m;
	while (tab_mot[i] != '\0')
	{
		i++;
	}
	while (k<=(Max))
	{
		k=k+i;
		j++;
	}
	printf("Vous pouvez recopier votre mot %d fois \n",j);
	if (j<=longueur)
		return 0;
	else
	{
		while (longueur != 0)

		{
			for(i=0;tab_mot[i+1] == '\0';i++)
			{

				tab_mot[i]=tab_taille[m];
				m++;
			}

			longueur--;

		}
		return 1;
	}
}