C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

fonction sscanf

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
daniel
Guest





PostPosted: Wed Apr 20, 2005 3:07 pm    Post subject: fonction sscanf Reply with quote



Bonjour,

J'ai un problème avec la fonction sscanf sous visual C++.
La compilation se fait bien, mais j'ai au lancement "Runtime error"

Voici le programme tout simple:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <conio.h>




float seuil1[5];





/***********************************************
Fonction main
***********************************************/
void main(int argc, char* argv[])
{
int i=0;
//float x = 0;

char ligne[80] = "1.4 1.5 1.6 1.7 1.8,";


sscanf(ligne, "%f", seuil1[0]);
}

Chose bizarre, si je decommente float x; ça marche

merci d'avance

Daniel

Back to top
Jean-Marc Bourguet
Guest





PostPosted: Wed Apr 20, 2005 3:13 pm    Post subject: Re: fonction sscanf Reply with quote



daniel <daniel (AT) free (DOT) fr> writes:

Quote:
sscanf(ligne, "%f", seuil1[0]);

Il faut une adresse, pas un pointeur. Donc &seuil1[0].
Mais en C++ on aurait plutôt tendance à utiliser des
stringstream et >>, ce qui aurait évité le problème de type.

A+

--
Jean-Marc
FAQ de fclc++: http://www.cmla.ens-cachan.fr/~dosreis/C++/FAQ
C++ FAQ Lite en VF: http://www.ifrance.com/jlecomte/c++/c++-faq-lite/index.html
Site de usenet-fr: http://www.usenet-fr.news.eu.org

Back to top
daniel
Guest





PostPosted: Wed Apr 20, 2005 4:01 pm    Post subject: Re: fonction sscanf Reply with quote



Bonsoir,

Merci pour la reponse.
Je me suis trompé en recopiant, j'ai bien
&seuil1[0]


Jean-Marc Bourguet wrote:
Quote:
daniel <daniel (AT) free (DOT) fr> writes:


sscanf(ligne, "%f", seuil1[0]);


Il faut une adresse, pas un pointeur. Donc &seuil1[0].
Mais en C++ on aurait plutôt tendance à utiliser des
stringstream et >>, ce qui aurait évité le problème de type.

A+



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.