新手求解答。为什么输入0的时候无法跳到最后一行。该如何解决

新手求解答。。为什么输入0的时候无法跳到最后一行。。
#include <iostream>
using namespace std;
int main()
{
int a;
for(;;)
{
cin>>a;
switch (a)
{
case 1:cout<<'1'<<endl;
case 2:cout<<'2'<<endl;
case 3:cout<<'3'<<endl;
case 4:cout<<'4'<<endl;
case 5:cout<<'5'<<endl;
default:cout<<'6'<<endl;
}
if (a=0) 
{
goto x;
}
}
x: cout<<'0'<<endl;
return 0;
}
------解决方案--------------------
if (a=0)     =>      if (a==0)
------解决方案--------------------
果然是goto呢.......
if(0==a)
还有case后面break
case 1:cout<<'1'<<endl;break;
------解决方案--------------------
这里不是 == 的话,
if (a=0)  // a=0,返回0,不执行goto语句
{
goto x;
}