Bonjour,

J'ai un header ("CString.h") associé a du code ("CString.cpp") et un fichier de programme principal ("main.cpp").

Je compile sous mingw

dans CString.h :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
class CString
{
    public:
    CString();
    CString (char Chaine[]);
 
    void SetString(char Chaine[]);
    void GetString(char Chaine[]);
    char GetChar(int Index);
    int Length();
    void Affiche();
};
dans CString.cpp :
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
#include <stdio.h>
 
class CString
{
    private:
    char mc_Chaine[50];
 
    public:
    CString::CString()
    {
        for(int intI = 0; intI < 50; intI++)
        {
            mc_Chaine[intI] = '\0';
        }
    }
 
    CString::CString (char Chaine[])
    {
        SetString(Chaine);
    }
 
    void CString::SetString(char Chaine[])
    {
        int intI = 0;
        while((Chaine[intI] != '\0') && (intI < 49))
        {
            mc_Chaine[intI] = Chaine[intI];
            intI++;
        }
        while (intI < 50)
        {
            mc_Chaine[intI] = '\0';
            intI++;
        }
    }
 
    void CString::GetString(char Chaine[])
    {
        Chaine = mc_Chaine;
    }
 
    char CString::GetChar(int Index)
    {
        return mc_Chaine[Index];
    }
 
    int CString::Length()
    {
        int intI = 0;
        while(mc_Chaine[intI] != '\0')
        {
            intI++;
        }
        return intI;
    }
 
    void CString::Affiche()
    {
        printf("Valeur = \"%s\" longueur = %d.", mc_Chaine, Length());
    }
};
et dans main.cpp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <stdio.h>
#include "CString.h"
 
int main(int argc, char **argv)
{
    CString s = CString();
    s.Affiche();
	return 0;
}
quant je compile j'ai ca sur le log de codeblocs :
Citation Envoyé par CodeBlocs
Project : Console application
Compiler : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\ppi\Bureau\CodeBlocsCode\
--------------------------------------------------------------------------------
Switching to target: default
Precompiling header: CString.h
Compiling: toto.cpp
Linking console executable: C:\Documents and Settings\ppi\Bureau\CodeBlocsCode\test.exe
CString.h.gch: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
Ou ai-je merdé ?