All pastes #277648 Raw Edit

Mine

public text v1 · immutable
·published 2006-12-13 13:31 UTC
rendered paste body
//connect.h

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>

char message[100][7];
int maxpartie=0;
char nom[256];
int nump;
int maxpartie2;
int nump2;


int fd1;
int chargerpartie()
{
bzero(message,sizeof(message));	
	fd1=open("partie", O_RDWR);
	while (1)
	{
		read(fd1,message[maxpartie],7);
		printf ("%d %s",maxpartie,message[maxpartie]);
		if (!strcmp(message[maxpartie],"mapend\n")) break;
		maxpartie++;	
		
	}
		
	maxpartie--;
	close(fd1);
	
	return maxpartie;

}

int liberemap()
{
	chargerpartie();
	message[nump-1][5]='0';
	//sauvegardertable();
}

int libre()
{
	int i;
for (i=0;i<=maxpartie;i++)
{
	if (message[i][5]=='0')
	{
	
    message[i][5]='1';		
	return i+1;	

	}
	}
return -1;
}

int recherchevs() //recherche les tables ayant une personne connectée
{
int i;
	
	
	for (i=0;i<=maxpartie;i++)
{
	
	if (message[i][5]=='1')
	{
	
 
	return i+1;	

	}
	
}
}

int sauvegardertable() //Sauvegarde la table modifié en fonction du résultat
{
	char ad[20],r[3];
	strcpy(ad,"partie");
	strcpy(r,"w");
	FILE *f;
	f=fopen(ad,r);
	int i=0;
	//for (i=0;i<100;i++)
	//{
	
		fprintf(f,"%s\n",message[i]);
	//}
	fclose(f);
	//fd1=open("partie", O_RDWR);
	//write(fd1,message,7*(maxpartie+1));
	
	//close (fd1);
}