logical problem

So, I've just started to program in C++, and I inherited a program to continue its development. So, i have to read these file wich contains three columns. The default value for column 1 is 1, for column 2 is 0 and for column 3 is also 0. In this case, data must be read normally. Column 3 valkue represents an important spot, and column 2 value adds up every time columns 3 number is different from 0. Column 1 value changes to column 2 value at some points. What i need is the following: every time columns 3 value equals 3, i must record column 2 value e do some routine every time column 1 has this value, and otherwise do the regular routine. I believe it's easier if i copy the code:

int i
int k
for (i=1;i<lines;i++)
if (column3()=3)
k=column2();
if (column1()!=k)
do routine a;
if (column 1()=k)
do routine b;

The problem is i'm only gettin routine a, even when column 1 = k. How can i correct this? Thanks in advance.
= is the copy assignment operator
== is the equality comparison operator
You've used assignment instead of comparison.
Actually i used comparison, i copied it wrong cause I was on a hurry.
Please copy and paste your actual code, don't rewrite it manually. Make sure you place it [code]between code tags[/code] for syntax highlighting.
Last edited on
Ok. I'm just not copying the routines because they're huge and i know they're fine, i just can't activate the second one.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
for (i=1;i<(lines);i++)
                {   
                     if (column3()==3)
                        {
                            k==column2();
                           
                      }
                   
                    
                        if (column1() != k && column1() !=0)
                    {
                    
                       
                    do routine.a;

                     }    
                    
                    
                         else if (column1() == k && column1() != 0)
                    {
                        
                        
                        do routine.b;
		
                    nextline();
                    
                }
Where is k given an initial value?
This statement is a comparison, not an assignment:
k==column2();
Oh, that's right. There were so many comparisons that i haven't noticed that assingment in the middle. It worked, thank you so much!
Topic archived. No new replies allowed.