Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1253 connectés 

  FORUM HardWare.fr
  Programmation

  Probleme de base en c++ !

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Probleme de base en c++ !

n°31077
bab light
Posté le 12-05-2001 à 14:32:36  profilanswer
 

Bon je suis pas une bete en c++ , meme carement pas et j ai un probleme de syntaxe avec : strcomp  
Je veux comparer des chaines de caractere se trouvant dans une structure avec une chaine de caractere saisie par l utilisateur et stocke dans une variable !  
tout d abord est ce que c bien strcomp que l on doit utiliser et surtout est ce que la syntaxe se rapporche de ca ?  
if   (strcmp(t_trajet[b].depart_de ,depart)== 0)
 
Voila alors t_trajet c le tableau de structure (non sans blague :) ) , et depart la variable ou est stocke la chaine de caratere entre par l utilisateur !  
Quand a ==0 c bien pour dire quand y pas de difference fais ca non ?  
bon j espere que j ai reussi a exposer mon probleme clairement !  
merci d avance  
bab light

mood
Publicité
Posté le 12-05-2001 à 14:32:36  profilanswer
 

n°31087
BENB
100% Lux.
Posté le 12-05-2001 à 15:12:03  profilanswer
 

bab light a écrit a écrit :

Bon je suis pas une bete en c++ , meme carement pas et j ai un probleme de syntaxe avec : strcomp  
Je veux comparer des chaines de caractere se trouvant dans une structure avec une chaine de caractere saisie par l utilisateur et stocke dans une variable !  
tout d abord est ce que c bien strcomp que l on doit utiliser et surtout est ce que la syntaxe se rapporche de ca ?  
if   (strcmp(t_trajet[b].depart_de ,depart)== 0)
 
Voila alors t_trajet c le tableau de structure (non sans blague :) ) , et depart la variable ou est stocke la chaine de caratere entre par l utilisateur !  
Quand a ==0 c bien pour dire quand y pas de difference fais ca non ?  
bon j espere que j ai reussi a exposer mon probleme clairement !  
merci d avance  
bab light




 
C'est du C, et effectivement on peut l'ecrire comme ca... bon souvent on prefere
if (!strcmp(str1, str2)) qui est plus compact...

n°31106
haahhahaha​ha
Posté le 12-05-2001 à 18:11:12  profilanswer
 

c ca. donc ou est ton prob ?


---------------
haahhahahaha == TheJackal
n°31108
darkoli
Le Petit Dinosaure Bleu
Posté le 12-05-2001 à 18:42:37  profilanswer
 

http://msdn.microsoft.com/library/ [...] s_6g1c.htm
 
lstrcmp
The lstrcmp function compares two character strings. The comparison is case sensitive.  
 
To perform a comparison that is not case sensitive, use the lstrcmpi function.  
 
int lstrcmp(
  LPCTSTR lpString1,  // first string
  LPCTSTR lpString2   // second string
);
Parameters
lpString1  
[in] Pointer to the first null-terminated string to be compared.  
lpString2  
[in] Pointer to the second null-terminated string to be compared.  
Return Values
If the string pointed to by lpString1 is less than the string pointed to by lpString2, the return value is negative. If the string pointed to by lpString1 is greater than the string pointed to by lpString2, the return value is positive. If the strings are equal, the return value is zero.  
 
Remarks
The lstrcmp function compares two strings by checking the first characters against each other, the second characters against each other, and so on until it finds an inequality or reaches the ends of the strings.  
 
The function returns the difference of the values of the first unequal characters it encounters. For example, lstrcmp determines that "abcz" is greater than "abcdefg" and returns the difference of z and d.  
 
The language (locale) selected by the user at setup time, or through Control Panel, determines which string is greater (or whether the strings are the same). If no language (locale) is selected, the system performs the comparison by using default values.
 
With a double-byte character set (DBCS) version of the system, this function can compare two DBCS strings.  
 
The lstrcmp function uses a word sort, rather than a string sort. A word sort treats hyphens and apostrophes differently than it treats other symbols that are not alphanumeric, in order to ensure that words such as "coop" and "co-op" stay together within a sorted list. Note that in 16-bit versions of Windows, lstrcmp uses a string sort. For a detailed discussion of word sorts and string sorts, see the Remarks section of the reference page for the CompareString function .  
 
Requirements  
  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

n°31111
haahhahaha​ha
Posté le 12-05-2001 à 19:01:13  profilanswer
 

ca c lekivalent Windows mais les deux marchent sauf si tu fait des chaines des char unicode. Dans ce cas il faut prendre lstrcmp absolument


---------------
haahhahahaha == TheJackal

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation

  Probleme de base en c++ !

 

Sujets relatifs
interfacer ma base access 2000 avec une page web[VB6] Pb lecture d'une valeur de type DWORD dans la base de registre
Migration d'un base Access vers SQL Server[perl] problème avec le module Sys::Syslog
Exporter une base MYSQL d'un hébergeur vers un autre....Probleme de compilation en OPENGL!!!!
[ASP] problème d'accès à une base access depuis global.asaBase de donnees et ASP pti probleme
Problème sur une fonction C++ de base...Probleme de maj base access en asp
Plus de sujets relatifs à : Probleme de base en c++ !


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR