bjour , je cherche comment je converti une variable AnsiString en Char* .
voila mon code et merci d'avance.
si quelqu'un a une autre astuce voila mon code :
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
 
void __fastcall TForm4::RzRapidFireButton3Click(TObject *Sender)
{
using namespace std;  int b;   char c1[1000], c2[1000], *tmp1, *tmp2, *dep, *arr;
    int nbr = 0;      char ligne_lue[999];
FILE * f; FILE * f1;   FILE * f2; FILE * f21;
  dep="TCP.EXCLUDED_NODES=(192.168.0.1)";
  //arr="TCP.EXCLUDED_NODES=(10.1.17.222)";
 
Table1->First();
while (!(Table1->Eof))
{
Variant arr=Table1->FieldByName("Nomm")->AsString;
Table1->Next();
 
}
AnsiString txt = VarToStr(arr);
txt="TCP.EXCLUDED_NODES=("+txt+")";
arr=txt;
ShowMessage("lire adresse.");
 
f = fopen ("C://oracle//ora92//network//admin//sqlnet.ora", "r");
f1 = fopen ("c://tata.txt", "w");
ShowMessage("ouvrir fichier.");
    while (fgets(c1,999,f))
    {
        strcpy(c2,"");
        tmp1 = c1;
        while(strlen(tmp1))
        {
            tmp2 = strstr(tmp1, dep);
            if (tmp2)
            {
                strncat(c2, tmp1, tmp2 - tmp1);
                strcat(c2, arr);
                tmp1 += ((tmp2 - tmp1) + strlen(dep));
                nbr++;
            }
            else
            {
                strcat(c2, tmp1);
                tmp1 += strlen(tmp1);
            }
        }
        fputs(c2,f1);
    }
ShowMessage("copier dans autre fichier");
 
fclose (f); fclose (f1);
 
f21 = fopen ("c://tata.txt", "r");
f2 = fopen ("C://oracle//ora92//network//admin//sqlnet.ora", "w");
 
 while(fgets(ligne_lue, 999, f21) != NULL){
 
 fprintf(f2, "%s", ligne_lue);
 
  }
  fclose (f2); fclose (f21);
  remove("c://tata.txt");
ShowMessage("recopier dans original");
}