Computer Hope

Software => Computer programming => Topic started by: liambiscuit on April 24, 2009, 08:42:53 PM

Title: [C++] In the statement -- -- What does i++ mean?
Post by: liambiscuit on April 24, 2009, 08:42:53 PM
-- The statement is
   for ( int i = 2; i < 30; i++ )
   {
   --
Based on my assumption, i++ means i+1... but -- I don't code in C++ at all.
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: gh0std0g74 on April 24, 2009, 10:05:27 PM
i++ mean post increment.  equivalent to i=i+1

edit: it means "use the value of i first, then increment"
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: Helpmeh on April 25, 2009, 10:25:19 AM
i++ mean post increment.  equivalent to i=i+1
Like in batch,

set /a num+=1
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: Geek-9pm on April 25, 2009, 06:23:26 PM
Like in batch,

set /a num+=1

C++  is NOT like batch at all.
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: x2543 on April 25, 2009, 06:40:59 PM
 
C++  is NOT like batch at all.

I think he meant to say that set /a num+=1 is the batch equivalent to the C++ command, does same type of thing.
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: Geek-9pm on April 25, 2009, 06:51:39 PM

I think he meant to say that set /a num+=1 is the batch equivalent to the C++ command, does same type of thing.

OK, I see what you mean. On my computer
set /a num=+1
gives the value as 1
Maybe he meant
set /a num=num+1
Or did I miss something? What did I miss?
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: Helpmeh on April 25, 2009, 07:27:15 PM
OK, I see what you mean. On my computer
set /a num=+1
gives the value as 1
Maybe he meant
set /a num=num+1
Or did I miss something? What did I miss?

set /a num+=1 and
set /a num=%num%+1
are the same thing. It will return 1 because a blank variable is equaled to 0, but also a blank line. In math, it's equaled to 0, but with echo it counts as nothing being there.
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: mohammad miyan on April 27, 2009, 12:54:37 AM
i++;

simply mean
i=i+1;
i++; will just increament value of i by 1.

in c,or c++
i++,++i are same if. if they are not used with other variable.
in the same way --i,i-- are  same.

consider
i=5;
i++;

now the value of i is simply 6;
i=5
++i;
again value of i is 6;

but u just consider statement
i=5;
c=i++;
the value of c is 5, i is 6.
i=5;
c=++i;
the value of c is 6,i is 6;
Title: Beep
Post by: Ralph Spencer on April 28, 2009, 01:26:46 AM
++ is an unary increment operator which increments the value of the operand by 1. I'd recommend reading books about C++. :)
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: Geek-9pm on April 28, 2009, 10:16:02 AM
Quote
books about C++.
So if I go to the library and ask for a book about C++
they will give me a book about D
Which comes after C.
Is that right?   ::)
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: x2543 on April 28, 2009, 11:23:37 AM
So if I go to the library and ask for a book about C++
they will give me a book about D
Which comes after C.
Is that right?   ::)

very funny  :P
Title: Re: [C++] In the statement -- -- What does i++ mean?
Post by: Ralph Spencer on April 29, 2009, 01:14:26 AM
Never knew your librarian uses a C++ compiler for everything that is told. Anyways you should get "Expression syntax" because "give" or "me" or "a" or "book" or "about" or "C++" none are valid in C++ syntax. Try
Code: [Select]
library.getBook("C++ for dummies");
If that fails refer to the manual for that librarian.