/** Fonction qui coupe une chaine bonjourXbonsoir en deux strings : bonjour bonsoir et qui renvoit la position de bonsoir. Comportement indéfini pour x==0 **/ char * cutAndGo(char * src, char x){ while(src[0]){ if(src[0]==x){ src[0]=0; return src+1; } } return NULL; }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question/************************************************* * stringTochar_array * *************************************************/ char *stringTochar_array(System::String ^s) { char* l = new char [s->Length]; int i=0; while(i<s->Length) { l[i]=s[i]; i++; } l[i]='\0'; return l; } /************************************************* * prefixe * *************************************************/ char *prefixe(char *s,char c) { int i=0; char* l = new char [500]; while(s[i]!=c && (unsigned int)i<strlen(s)) { l[i]=s[i]; i++; } l[i]='\0'; return l; } /************************************************* * sufixe * *************************************************/ char *sufixe(char *s,char c) { int i=0,j=0; char* l = new char [500]; while(s[i]!=c) { i++; } i++; while((unsigned int)i<strlen(s)) { l[j]=s[i]; j++; i++; } l[j]='\0'; return l; }
char *donnee(char* rubrique, char *sousRubrique ) { char* l char* l new char [500]; System::String ^line; System::IO::StreamReader ^sr=gcnew StreamReader("thread.ini"); line = sr->ReadLine(); char_string ch; while (line != nullptr && strcmp(ch.stringTochar_array(line),rubrique)!=0) { line = sr->ReadLine(); } line = sr->ReadLine(); while (line != nullptr && strcmp(ch.prefixe(ch.stringTochar_array(line),'='),sousRubrique)!=0) { line = sr->ReadLine(); } l= ch.sufixe(ch.stringTochar_array(line),'='); return l; }
while(ch.compare_heure(date_time,ini.donnee("[thread-time]","time1"))==-1) //si l'heure correspond à celle du fichier thread.ini (time1), lancement du thread1) { date_jour=gd.date_heure_jour(); sprintf(date_time,"%d:%d:%d",date_jour.Hour,date_jour.Minute,date_jour.Second); } thread1^ Object1 = gcnew thread1(); Thread^ InstanceCaller1 = gcnew Thread(gcnew ThreadStart(Object1, &thread1::premier_thread)); InstanceCaller1->Start(); // lancer Thread1 i++; InstanceCaller1->Join(); // le Thread2 ne se lance que quand le Thread1 est fini
// fonction qui compare une chaine b pour // verifier si elle commence par le prefixe bool prefixEquals(const char * prefix, const char *b,char sep){ for(int i=0; prefix[i] != 0 && prefix[i] != 0;i++){ if(prefix[i]==sep && b[i]==sep){ return true; } } return false; }