   DrawMap(map);
  void DrawMap(int *map){ int i; for (i=0; i<10*10; i++) { if (map==10|20|30|40|50|60|70|80|90) { cout<<''\n''<; } else { cout<<map; } }}that code draws out a map from a file, well its supposed to. but instead what happens is it &#111;nly does these lines:<b> if (map==10|20|30|40|50|60|70|80|90) { cout<<''\n''<<map; }</b>so instead of getting a nice and orderly 10by10 map like this:1111111111100000000111000000111110000111111100111111100001111100000011111000011110000000011111111111i get this:11111111111000well, you get the idea.any ideas &#111;n how to help??  </i>  
quote:if (map[i]==10|20|30|40|50|60|70|80|90) {This doesn't do what you think it does. Instead you need something like:if ( (map[i] == 10) ||(map[i] == 20) ||(map[i] == 30) ||(map[i] == 40) ||(map[i] == 50) ||(map[i] == 60) ||(map[i] == 70) ||(map[i] == 80) ||(map[i] == 90)) {   Still not great style, but at least does what you'd want it to.  edit: [i] showing up as italics   [edited by - SiCrane on February 2, 2004 10:38:15 PM];  To be more educational about it:PART 1 On pipes and "OR".|| (double pipe) is logical OR. You want to have complete expressions between each double-pipe, because it will interpret everything between each double-pipe as an expression. In C, constant numbers are valid expressions; 0 is considered "false" and anything else is considered "true".  | (single pipe) is bitwise OR. After evaluating the expressions between the single-pipes, they all have their binary represenations OR''d together.Also, ''=='' and other relational operators have higher precedence than either OR.Thus, the statementif map[i]==10|20|30|40|50|60|70|80|90  becomes (I am going to invent the notation "%xxxxxxxx%b" to indicate the binary representation of a number - I''m only using 8 bits here because the numbers are small enough)if (%0000000x%b|%00010100%b|%00011110%b|%00101000%b|%00110010%b|%00111100%b|%01000110%b|%01010000%b|%01011010%b)  (where x depends on whether map[i] == 10) and thusif (%0111111x%b)  which is of course true (non-zero). (I actually wasn''t sure about the operator precedence, but if it were the other way then it would be comparing map[i] to %01111110%b each time, i.e. 126, so you''d have the opposite problem - everything on one line.)PART 2What condition are you checking?You want to move down a line every 10th entry, yes? So you want to *count* 10 entries and then put the newline. What''s *counting* your entries here? It''s not map[i], it''s just i. PART 3Simplifying your logicFirst, the only thing that depends on i is whether you print a newline, so that''s the only part that should go in your if/else check. (You should also be using << endl for newlines because it will make sure the buffer is flushed and that everything actually appears on screen - I run into problems because of that all the time in C++ due to my carelessness :/ )Second, there is a much cleaner, simpler idiom for expressing the condition of doing something "every 10th time".What is the property shared by every 10th number starting from 0? ... Ok, that was easy; they''re divisible by 10. That is to say, the modulus   base 10 (remainder when you divide by 10) is zero. In C and C++ (and Java... and Perl... etc...), we get at this operation with ''%''.PART 4Putting it all together (and using [source] tags  ) void DrawMap(int *map) {  // Please excuse my radically different indentation style.  // You should consider supplying the height and width of the  // map as parameters too, so that you can use those values in  // the loop and thus print different-sized maps.  int i;  // in C++, you can declare the int within the actual for  // statement instead, as "for (int i = 0; ... etc".  for (i = 0; i < 10 * 10; i++) {    if (i % 10 == 0) cout << endl;    // the l33t write the condition as "(!(i % 10))"    cout << map[i];  }  cout << endl; // make sure the last line actually gets printed.  // You could instead put the if statement second in the loop,  // and compare the modulus value to 9 (last item of a line).}