# Thread: Problem in the loop

1. ## Problem in the loop

I am in the early stages of creating a game of fifteen but i am having a problem. When i run this program i can do "up" and "down" all day long, but when i try "left" or "right" or type anything else in for that matter it performs "down".

I know there is a simple answer to this, but i cant seem to find the problem and its been driving me nuts!

if you have a better idea of how i should be using functions in this code feel free to let me know

heres the code
Code:
```#include <stdio.h>
#include <string.h>

void show(int numbers[][4]);
void move(char input[]);

main()
{
int numbers[4][4]={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2, 0};
int correct[4][4]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
char input[5];
int x, y, tmp;
x=y=3;
show(numbers);
move(input);
while(numbers != correct)
{
if(strcmp(input, "up") == 1)
{
tmp=numbers[y][x];
numbers[y][x]=numbers[--y][x];
numbers[y][x]=tmp;
}
else if(strcmp(input, "down") == 1)
{
tmp=numbers[y][x];
numbers[y][x]=numbers[++y][x];
numbers[y][x]=tmp;
}
else if(strcmp(input, "left") == 1)
{
tmp=numbers[y][x];
numbers[y][x]=numbers[y][--x];
numbers[y][x]=tmp;
}
else if(strcmp(input, "right") == 1)
{
tmp=numbers[y][x];
numbers[y][x]=numbers[y][++x];
numbers[y][x]=tmp;
}
show(numbers);
move(input);
}
}

void show(int num[][4]) /***Display The Layout of the Game***/
{
int i, j;
for(i=0; i <= 3; i++)
{
for(j = 0; j <= 3; j++)
printf("&#37;5d", num[i][j]);
printf("\n\n");
}
}

void move(char input[]) /***inputing what space they want to switch with 0***/
{
char c;
int i;
printf("Please enter in the space you want to switch with 0 by indicating \"up\", \"down\", \"left\" or \"right\"\n");
for(i=0; c!='\n'; i++)
input[i]=(c=getchar());
input[i]='\0';
}```

2. strcmp returns 0 when it matches, not 1
RTM

3. lol, thank you, duh!