All pastes #778337 Raw Edit

Someone

public text v1 · immutable
·published 2007-11-17 14:20 UTC
rendered paste body
#include "stdio.h"
#include "string.h"
#include "stdlib.h"

int main (void)
{

FILE* f1;
f1 = fopen("f1.txt", "r");

FILE* f2;
f2 = fopen("f2.txt", "r");

FILE* f3;
f3 = fopen("f3.txt", "w");

int n=0;
char* p[100];
char t[100];
char* temp;
char* c[100];
int i,h;

while (fgets(t,100,f1)) // verification de l'ouverture du fichier F1
	{
	p[n]=(char*) malloc(100*sizeof(char));
	strcpy(p[n],t);
	n++;
	}

while (fgets(t,100,f2))// verification du fichier F2
	{
	p[n]=(char*) malloc(100*sizeof(char));
	strcpy(p[n],t);
	n++;
	}
	
	for (i=0;i<n-1;i++)// trie les valeurs du tableau p par nom
	{
	
	for (h=i+1;h<n+1;h++)
		{
		if (strcmp (p[i],p[h])>0)
		{
			temp=p[i];
			p[i]=p[h];
			p[h]=temp;
		}
		}	
	
	}
	
	for (i=0;i<n;i++)// ecrit les valeur du tableau p dans le fichier f3
		{
		fputs(p[i],f3);
		}
		
		char* a;
		char* b;
                a=(char*) malloc(2*sizeof(char));
		for (i=0;i<n;i++)
		{	
		c[n]=(char*) malloc(2*sizeof(char)); // tableau ou mettre les valeurs
		
		b = p[i];// p[i] tableau ou sont les valeurs 
		
		strncpy( a, b + 20, 2);
		c[i] = a;
		}
	printf(c[2]);
}