Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 10th, 2004, 10:46 PM   #11
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4 Benoit is on a distinguished road
I know, but if it's

variable = value

Then wouldn't that be working from left to right? C assigns right to left
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4
Benoit is offline   Reply With Quote
Old Oct 10th, 2004, 11:28 PM   #12
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
the calculation of value must occur first
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Oct 10th, 2004, 11:55 PM   #13
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Quote:
Originally posted by Infinite Recursion@Oct 11 2004, 02:37 AM
I was a late bloomer on this one... I was wondering when you guys were going to mention this...

Quote:
== is a comparison and = is assignment

lol
I can't believe I missed that. :blink:
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Oct 11th, 2004, 2:39 AM   #14
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
hehe, and i think for most people who have programmed for a while

value = variable <---- is just wrong on so many levels

variable = (value with possible workingout's) < much nicer

i feel it is also easier to read as if you have a lot of calculations over multiple lines its easier to look at the start of a calculation to find the variable then at the end.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Oct 11th, 2004, 2:55 AM   #15
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4 Benoit is on a distinguished road
Quote:
Originally posted by Mjordan2nd+Oct 11 2004, 04:55 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Mjordan2nd @ Oct 11 2004, 04:55 AM)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-Infinite Recursion@Oct 11 2004, 02:37 AM
I was a late bloomer on this one... I was wondering when you guys were going to mention this...

Quote:
== is a comparison and = is assignment

lol
I can't believe I missed that. :blink: [/b][/quote]
:blink: :blink:
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4
Benoit is offline   Reply With Quote
Old Oct 11th, 2004, 10:16 AM   #16
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
One more thing - if you use an array for the months, it'll make it so much easier:
int month;
std::string months[12] = "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December";
char mon[10];
And later:
mon = c_str(months[month]);
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Oct 11th, 2004, 4:38 PM   #17
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 4 TecBrain is on a distinguished road
Thanks guys, my following question:

If user enter 1 then this month represent January:

How could I assign the variable mon to be equaled to January?

if (month == 1)

mon = "January";

But this wont work.. I don’t know why.
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Old Oct 11th, 2004, 4:42 PM   #18
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4 Benoit is on a distinguished road
Use strcpy(mon, "January"); make sure mon is big enough to hold the word
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4
Benoit is offline   Reply With Quote
Old Oct 11th, 2004, 4:45 PM   #19
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 4 TecBrain is on a distinguished road
Is that right: :unsure:


int date;
 int month;
 int year;
 double mon;
 
 cout << "Please Enter the date(EX: 1 or 2)" << endl;
 cin >> date;
 cout << "Please Enter the month(EX 1 or 2)" << endl;
 cin >> month;
 cout << "Pleae Enter the year(2004 or 2003)" << endl;
 cin >> year;
 
 
 if (month == 1)
 strcpy(mon, "January");
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Old Oct 11th, 2004, 4:47 PM   #20
dnathe4th
Programmer
 
Join Date: Oct 2004
Posts: 32
Rep Power: 0 dnathe4th is on a distinguished road
use Ooble's array to do it, it's much cleaner and easier. I agree with his method.
__________________
&lt;CENTER&gt;<span style='font-size:17pt;line-height:100%'>My Homepage</span>&lt;/CENTER&gt;
dnathe4th is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:51 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC