|
From: J H. <jsh...@ho...> - 2007-07-08 17:03:24
|
i cant figure out how to use the strcmp to compare the string noble to the=
object helium with the member string name...??!!this is the error that is =
stopping the compiler...44 C:\Dev-Cpp\Untitled1.cpp no matching function fo=
r call to `strcmp(std::string&, std::string&)' #include <stdio.h>#include =
<iostream>#include <string.h>#include <cstring>using namespace std;struct e=
lements{ string aname; int atomic_no; float atomic_weight=
; }helium, neon, argon, krypton, xenon, radon; int x;main(){heliu=
m.aname =3D "helium"; helium.atomic_no =3D 2; helium.atomic_weigh=
t =3D 4; neon.aname =3D "neon"; neon.atomic_no =3D 10; neon.ato=
mic_weight =3D 20.1797; argon.aname =3D "argon"; argon.atomic_no =
=3D 18; argon.atomic_weight =3D 39.948; krypton.aname =3D "krypton"=
; krypton.atomic_no =3D 36; krypton.atomic_weight =3D 83.80; xe=
non.aname =3D "xenon"; xenon.atomic_no =3D 54; xenon.atomic_weight=
=3D 131.29; radon.aname =3D "radon"; radon.atomic_no =3D 86; =
radon.atomic_weight =3D 222.0176; string noble; string title("\n\t You =
have selected :\t"); string no("\n\t The atomic number for "); string is(" =
is:\t"); string wgt("\n\t The atomic weight is:\t");printf ("\t The Beginin=
g of the Periodic Table of the Elements \n");printf ("\t In the hopes of le=
arning C programming and elemental values. \n\n\n");cout << "\t Please ente=
r a Noble Gas you would like to examine." ;cin >> noble; if (strcmp (noble,=
helium.aname)=3D=3D0) { cout << title << helium.aname; =
cout << no << helium.aname << is << helium.atomic_no; cout << =
wgt << helium.atomic_weight;}; cin >> x; }this is what i have got=
so far... any help would be appreciatedthanks yohaan
_________________________________________________________________
See what you=92re getting into=85before you go there.
http://newlivehotmail.com=
|