Je cherche à optimiser un "programme".

Ce programme combine des caractères, ainsi, sur cet exemple, je récupère trois pointeurs de type string, que je cherche à mettre directement dans un string.

Je ne veux pas rajouter de commande supplémentaire, ce qui, je pense ralentirait le code.

Pourquoi le string : mot ne s'affiche pas ? (première partie de l'exemple).

J'ai essayé une autre version dans la deuxième partie de l'exemple.
Cette foi c'est le string : word, qui n s'affiche pas correctement.

Merci.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
#include <cstdlib>
#include <fstream>
#include "stdlib.h"
#include <stdio.h>
#include <sstream>
#include <string>    
#include <iostream>  
#include <cstring>
using namespace std;
 
int main(int argc, char *argv[])
{
 
 ofstream fichier("FileExit.txt", ios::out | ios::trunc); 
 ofstream fichier1("FileExit2.txt", ios::out | ios::trunc); 
 
 string mot;
 string str ("abcd");
 
 
  string::iterator it0;
    string::iterator it1;
      string::iterator it2;
 
 
  for ( it2=str.begin() ; it2 < str.end(); it2++ )
   {
    for ( it1=str.begin() ; it1 < str.end(); it1++ )
     {
      for ( it0=str.begin() ; it0 < str.end(); it0++ )
      {
 
         mot[0] = *it0;
          mot[1] = *it1;
           mot[2] = *it2;
 
 
    cout<<mot<<"  "<<*it2<<*it1<<*it0<<endl;
    fichier<<mot<<"   "<<*it2<<*it1<<*it0<<endl;
 
            }
          }
        }
    cout<<"------------Fin Premiere partie-----------------------"<<endl;
 
 
   string chaine = "acb";
   int taille = chaine.length();
 
   string word[taille];
 
 
  for (int i2=0; i2<taille; i2++)  
      { 
     for (int i1=0; i1<taille; i1++)  
      { 
       for (int i=0; i<taille; i++)   
          {
 
           word[0] = chaine.substr(i,1);
           word[1] = chaine.substr(i1,1);
           word[2] = chaine.substr(i2,1);
 
            cout<<word<<endl;
             fichier1<<word<<endl;
 
 
             }
           }
        }
 
 
    system("PAUSE");
    return EXIT_SUCCESS;
}