?
Solved

Comparing signed and unsigned values

Posted on 2005-04-21
6
Medium Priority
?
365 Views
Last Modified: 2010-04-01
Hi experts,

   How do I get rid of the following warning ?
 
  line 89 :  for(int i=0; i< group_1.size(); i++)

[C++ Warning] Meow.cpp(89): W8012 Comparing signed and unsigned values

 many thanks !
0
Comment
Question by:meow00
6 Comments
 
LVL 12

Expert Comment

by:andrewjb
ID: 13831921
for ( unsigned int i = 0 .....

?
0
 
LVL 16

Expert Comment

by:nonubik
ID: 13832063
or for(int i=0; i< (int)group_1.size(); i++)
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 13832113
Or, really, know what the correct tyoe of group_1.size() is, and use that for your index...

What's group_1 ?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 30

Assisted Solution

by:Axter
Axter earned 400 total points
ID: 13832538
Hi meow00,
>> for(int i=0; i< group_1.size(); i++)

If group_1 is an STL container, then you should be using size_t.

for(size_t i=0; i< group_1.size(); ++i)


David Maisonave :-)
Cheers!
0
 
LVL 86

Accepted Solution

by:
jkr earned 800 total points
ID: 13833644
If group_1 is an STL container, you could also use iterators, e.g.:

for ( [container]::iterator i = group_1.begin(); i != group_1.end(); ++i) {

//...
}

Another thing (a bit nitpicking)  - in all the loop variations, take 'group_1.end()' and 'group_1.size()' out of the loop, unless that value is not constant.
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 13841186
I feel somewhat cheated!
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question