Click here to Skip to main content
15,878,871 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
if c does not support foreach then what can we at that place
Posted
Updated 29-Jun-19 22:53pm

Macros[^]

-KR
 
Share this answer
 
v2
Quote:
if c does not support
There is NO foreach in C.

Quote:
hen what can we at that place
Use the standard for statement.
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 7-Oct-15 4:24am    
5ed, good answer.
Member 11835269 7-Oct-15 5:13am    
how ..?
CPallini 7-Oct-15 6:05am    
It depends on the collection you need to iterate over.
The C for statement is flexible and powerful, it gives you full control.
There is no foreach in C, or anything close. You need to rethink the issue and handle it with a standard loop: for, do, while etc. See https://msdn.microsoft.com/en-us/library/015az3wz.aspx[^].
 
Share this answer
 
get the length off array using --> int length=sizeof(array_name);
and use for loop using it length.
 
Share this answer
 
Comments
Stefan_Lang 1-Jul-19 3:45am    
Incorrect, Does not address the question. And 4 years late.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900