 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
daniel Guest
|
Posted: Wed Apr 20, 2005 3:07 pm Post subject: fonction sscanf |
|
|
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
|
|
| Back to top |
|
 |
daniel Guest
|
Posted: Wed Apr 20, 2005 4:01 pm Post subject: Re: fonction sscanf |
|
|
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 |
|
 |
|
|
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
|
|