IdentifiantMot de passe
Loading...
Mot de passe oubli� ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les r�ponses en temps r�el, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

[c++ Win32] Edit Control avec fopen


Sujet :

C++

  1. #1
    Membre confirm�
    Inscrit en
    D�cembre 2007
    Messages
    67
    D�tails du profil
    Informations forums :
    Inscription : D�cembre 2007
    Messages : 67
    Par d�faut [c++ Win32] Edit Control avec fopen
    Salut,
    Question s�rement stupide mais, je n�arrive pas depuis ce matin � afficher un texte � .txt � dans IDC_EDIT1 (Edit Control)

    Mon probl�me, c�est le retour � la ligne et la d�tection de la fin du fichier.

    Dans le fichier test.txt :
    0 0 0
    0 1 1
    1 0 1
    1 1 0

    et le programme :
    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
    	char temp[800];
    	int i=0;
    	char c;
    	const char* fichier;
    	fichier="test.txt";
    	FILE*   fp = NULL;
    	fp = fopen(fichier,"r");
     
    	 while (( c=fgetc(fp)) !=EOF)
    	{
    		//if(c=='\0') temp[i++]='\r\n';
    		temp[i++]=c;
    	}
     
    	if(fp) fclose(fp);
    	SetWindowText(GetDlgItem(hdlg,IDC_EDIT1),temp);
    merci beaucoup
    @+

  2. #2
    Membre �clair�
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    487
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Octobre 2007
    Messages : 487
    Par d�faut

    char temp[800];
    int i=0;
    char c;
    const char* fichier;
    strcpy(fichier,"test.txt");
    FILE* fp ;
    fp = fopen(fichier,"rt");

    while (( c=fgetc(fp)) >0)
    {
    //if(c=='\0') temp[i++]='\r\n';
    temp[i++]=c;
    }

    if(fp) fclose(fp);
    SetWindowText(GetDlgItem(hdlg,IDC_EDIT1),temp);

  3. #3
    Membre �clair�
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    487
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Octobre 2007
    Messages : 487
    Par d�faut

    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
    char temp[800];
    	int i=0;
    	char c;
    	const char* fichier;
    	strcpy(fichier,"test.txt");
    	FILE*   fp ;
    	fp = fopen(fichier,"rt");
     
    	 while (( c=fgetc(fp)) >0)
    	{
    		//if(c=='\0') temp[i++]='\r\n';
    		temp[i++]=c;
    	}
     
    	if(fp) fclose(fp);
    	SetWindowText(GetDlgItem(hdlg,IDC_EDIT1),temp);[/QUOTE]

  4. #4
    Membre confirm�
    Inscrit en
    D�cembre 2007
    Messages
    67
    D�tails du profil
    Informations forums :
    Inscription : D�cembre 2007
    Messages : 67
    Par d�faut
    Salut,
    Le programme fonctionne, mais, j�ai toujours les m�mes probl�mes
    @+

  5. #5
    Membre confirm�
    Inscrit en
    D�cembre 2007
    Messages
    67
    D�tails du profil
    Informations forums :
    Inscription : D�cembre 2007
    Messages : 67
    Par d�faut
    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
    		char temp[50];
    		int i=0;
    		char c;
    		const char* fichier;
    		fichier="DATA\\Logiques\\OU-EXCLUSIF.txt";
    		FILE* fp ;
    		fp = fopen(fichier,"rt");
     
    		while (( c=fgetc(fp)) !=EOF)
    		{
    			if(c=='\n') temp[i++]='\r';
    		temp[i++]=c;
    		}
     
    		if(fp) fclose(fp);
    		SetWindowText(GetDlgItem(hdlg,IDC_EDIT1),temp);

    Il y a du mieux, j�obtiens :

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    0 0  0
    0 1  1
    1 0  1
    1 1  0ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ3kîÌ(û

  6. #6
    Membre �clair�
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    487
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Octobre 2007
    Messages : 487
    Par d�faut
    Citation Envoy� par swo.line Voir le message
    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
    		char temp[50];
    		int i=0;
    		char c;
    		const char* fichier;
    		fichier="DATA\\Logiques\\OU-EXCLUSIF.txt";
    		FILE* fp ;
    		fp = fopen(fichier,"rt");
    
    		while (( c=fgetc(fp)) !=EOF)
    		{
    			if(c=='\n') temp[i++]='\r';
    		temp[i++]=c;
    		}
                     temp[i]='\0';
    		if(fp) fclose(fp);
    		SetWindowText(GetDlgItem(hdlg,IDC_EDIT1),temp);

    Il y a du mieux, j�obtiens :

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    0 0  0
    0 1  1
    1 0  1
    1 1  0ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ3kîÌ(û
    Tu doit ajouter le �\0�

  7. #7
    Membre confirm�
    Inscrit en
    D�cembre 2007
    Messages
    67
    D�tails du profil
    Informations forums :
    Inscription : D�cembre 2007
    Messages : 67
    Par d�faut
    Impeccable merci

  8. #8
    Membre �clair�
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    487
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Octobre 2007
    Messages : 487
    Par d�faut
    Citation Envoy� par swo.line Voir le message
    Impeccable merci
    N oubli pas de mettre

  9. #9
    Expert �minent
    Avatar de M�dinoc
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 41
    Localisation : France

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par d�faut
    "rt" n'est pas portable.
    "r" suffit, si on n'a pas fait n'importe quoi avec le projet.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parl� avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  10. #10
    Membre �clair�
    Homme Profil pro
    Inscrit en
    Octobre 2007
    Messages
    487
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Octobre 2007
    Messages : 487
    Par d�faut
    Citation Envoy� par M�dinoc Voir le message
    "rt" n'est pas portable.
    "r" suffit, si on n'a pas fait n'importe quoi avec le projet.

    D�apr�s mes connaissances rt est portable

  11. #11
    Expert �minent
    Avatar de M�dinoc
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 41
    Localisation : France

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par d�faut
    Tes connaissances ne doivent pas s'appeler n1256.pdf...
    Citation Envoy� par standard C99
    The argument mode points to a string. If the string is one of the following, the file is
    open in the indicated mode. Otherwise, the behavior is undefined.
    r open text file for reading
    w truncate to zero length or create text file for writing
    a append; open or create text file for writing at end-of-file
    rb open binary file for reading
    wb truncate to zero length or create binary file for writing
    ab append; open or create binary file for writing at end-of-file
    r+ open text file for update (reading and writing)
    w+ truncate to zero length or create text file for update
    a+ append; open or create text file for update, writing at end-of-file
    r+b or rb+ open binary file for update (reading and writing)
    w+b or wb+ truncate to zero length or create binary file for update
    a+b or ab+ append; open or create binary file for update, writing at end-of-file
    M�me cette clause dit "implementation-defined", donc non-portable:
    237) If the string begins with one of the above sequences, the implementation might choose to ignore the
    remaining characters, or it might use them to select different kinds of a file (some of which might not
    conform to the properties in 7.19.2).
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parl� avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. win32 api - EDIT control
    Par opc0de dans le forum C++
    R�ponses: 0
    Dernier message: 25/04/2011, 16h51
  2. [WIN32][VC60]Pb avec SetLayeredWindowAttributes
    Par Invit� dans le forum MFC
    R�ponses: 21
    Dernier message: 23/08/2006, 03h56
  3. Un edit control en lecture seule mais pas avec un fond gris?
    Par Magus (Dave) dans le forum Windows
    R�ponses: 2
    Dernier message: 04/12/2005, 21h58
  4. [Win32] Transparence d'un Edit Control
    Par bigbang dans le forum MFC
    R�ponses: 20
    Dernier message: 04/02/2005, 08h22
  5. [mfc]edit control
    Par marseillais57 dans le forum MFC
    R�ponses: 4
    Dernier message: 21/06/2004, 10h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo