문제

I'm trying to print out an array of 100 lf values into columns of ten. I was planning on inserting a new line whenever I hit the tenth data value in each line, but I'm having trouble with my if statement. "Left operand must be 1-value" is the error I keep running into. Here's the code as is:

for (x=0; x<100; x++)
    {
    if (x % 10 = 0)
        {
        printf("\n");
        }
    printf("|%-6.2lf|", i[x]);  
    }

Is there a cleaner way to do this?

올바른 솔루션이 없습니다

다른 팁

The problem is this line:

if (x % 10 = 0)

That should be the double-equals sign:

if (x % 10 == 0)

A common typo.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top