d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > C++ Help Please
Prev12
Add Reply New Topic New Poll
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
May 22 2012 11:34am
Quote (SlayingWhileInt0xicated @ May 22 2012 11:18am)
Still getting stuck on this if (system.length) thing

this is what I did

if(system.length () != 1)
{
  cout << "You have entered << temp << system << ". This is incorrect." endl;

i get an error that says: Request for member in 'length' in 'system' , which is of non-class type 'char'


the .length() method is part of the C# family. what you want to do is include strings.h or strings and then use the strlen() function.
Member
Posts: 827
Joined: Jan 16 2012
Gold: 0.00
Warn: 10%
May 22 2012 02:19pm
Why don't you post all your code here? Will be easier to spot the problems.
Member
Posts: 1,087
Joined: May 2 2005
Gold: 75.00
Jul 21 2012 01:50pm
There are a few methods to solve this issue but we need to see your code to tell where &/or what you did wrong to get a better picture of the overall problem your trying to solve. Just post your full code with code tags and you would get clearer descriptions of help.
Member
Posts: 9,099
Joined: Nov 23 2002
Gold: 2,911.26
Jul 29 2012 11:55pm
don't forget that the number can't be less than -273.15C

i would also say perhaps put in K and R calculations too!
Member
Posts: 21,407
Joined: Jun 15 2007
Gold: 120,303.00
Jul 29 2012 11:59pm
Quote (thestealthtarget @ 30 Jul 2012 15:55)
don't forget that the number can't be less than -273.15C

i would also say perhaps put in K and R calculations too!


major vouch here
Member
Posts: 9,099
Joined: Nov 23 2002
Gold: 2,911.26
Jul 30 2012 12:07am
I would also say to remove the ftemp and ctemp from the if statement and put in a universal statement at the bottom "-40ºC is equal to -40ºF" rather than what you are posting
Member
Posts: 7,094
Joined: Dec 24 2006
Gold: 1,100.00
Aug 27 2012 12:24pm
I refuse to help because of your signature hurting my eyes
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Aug 28 2012 03:35am
I had a similar issue one time before and realized it was just too much work to deal with (especially because I was in an intro course and it was unnecessary)

if your prof requires it then he should have told you how to deal with. Our Prof. told us to assume that the c++ code would only receive valid inputs.


if it is just length you are concerned about maybe throw the input into a string and then find the length of it.

This post was edited by Eep on Aug 28 2012 03:38am
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll