Código PHP:
#ifndef _MCadena_h_
#define _MCadena_h_
namespace MCadena{
const int MAXCAD=30;
const char FINCAD='\0';
typedef char TCadena[MAXCAD];
void CopiaCadena(TCadena s1,TCadena &s2);
bool IgualCadena(TCadena s1,TCadena s2);
}
#endif
Código PHP:
#include<iostream>
#include "MCadena.h"
namespace MCadena{
void CopiaCadena(TCadena s1,TCadena &s2){
int i;
i=0;
while((i<MAXCAD)&&(s1!=FINCAD)){
s2[i]=s1[i];
i++;
}
s2[i]=FINCAD;
}
bool IgualCadena(TCadena s1,TCadena s2){
int i;
i=0;
while((i<MAXCAD)&&(s1!=FINCAD)&&(s2!=FINCAD)&&(s1[i]==s2[i])){
i++;
}
return ((i>=MAXCAD)||(s1[i]==s2[i]));
}
}