当在while里的switch里用break的话,只能跳出switch!

// WhileSwitchBreak.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"

#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	int i = 0;
	while (true)
	{
		switch (i)
		{
		case 1:
			break;
		default:
			break;
		}
		cout<<i <<" ";
		i++;

		if (i>10)
		{
			break;
		}
	}
	cin>>i;
	return 0;
}

 结果为:0 1 2 3 4 5 6 7 8 9 10

原文地址:https://www.cnblogs.com/chunyou128/p/2227069.html