Shou Barrett
Shou Barrett

Reputation: 61

Cannot break c loop

Whenever I run this (part of a much larger file), when I get asked for inputs, if they are not numbers (letters or words) the code seems to loop and I'm not sure why.

while(rembox>=1){
    printf("%c> ", p );
    s=scanf("%d %d %c",&r , &k, &orin);
    if (r = 5 || k =10){
        *statement*
        rembox --;

    }
    else{
        rembox --;
        continue;
    }

Upvotes: 0

Views: 201

Answers (1)

berty
berty

Reputation: 2206

At this line :

if (r = 5 || k =10){

You are assigning values 5 and 10 to r and k variables.

What you wanted to do :

if (r == 5 || k ==10){

Upvotes: 3

Related Questions