Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
Loop declaration in C
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
gnanapoongothai
New Member
Join Date:
Jun 2007
Posts:
62
#1
Loop declaration in C
Aug 21 '07, 12:19 PM
for (int i =0;i<0;i++)
Is this kind of definition inside for loop is allowed in c standard.
kreagan
New Member
Join Date:
Aug 2007
Posts:
153
#2
Aug 21 '07, 12:26 PM
Originally posted by
gnanapoongothai
for (int i =0;i<0;i++)
Is this kind of definition inside for loop is allowed in c standard.
no, you cannot create a variable while assigning it a value in C. You can do that for C++ thought
it should be
[CODE=c]int i = 0;
for (i = 0; i < number; i++)[/CODE]
Also, your loop will always terminate from the first call because i is always greater than 0;
Comment
Post
Cancel
saranjegan
New Member
Join Date:
Feb 2007
Posts:
50
#3
Aug 21 '07, 02:40 PM
Originally posted by
kreagan
no, you cannot create a variable while assigning it a value in C. You can do that for C++ thought
it should be
[CODE=c]int i = 0;
for (i = 0; i < number; i++)[/CODE]
Also, your loop will always terminate from the first call because i is always greater than 0;
Yup you can create variable like this inside for loop , but your loop has no meaning !!?
Comment
Post
Cancel
gnanapoongothai
New Member
Join Date:
Jun 2007
Posts:
62
#4
Aug 22 '07, 01:07 PM
somebody give a clear idea if u can or cannot
Comment
Post
Cancel
sicarie
Recognized Expert
Specialist
Join Date:
Nov 2006
Posts:
4677
#5
Aug 22 '07, 01:09 PM
Originally posted by
gnanapoongothai
somebody give a clear idea if u can or cannot
I think you need to re-read the thread, your question has been answered.
I also changed the thread title as per the
Posting Guidelines
to describe your issue.
Comment
Post
Cancel
Banfa
Recognized Expert
Expert
Join Date:
Feb 2006
Posts:
9067
#6
Aug 22 '07, 01:11 PM
Originally posted by
saranjegan
Yup you can create variable like this inside for loop , but your loop has no meaning !!?
This is not true. Note this is a question about C. You can only create a variable in a for loop like that in C++.
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment