break.cpp

来自「c语言教程源码」· C++ 代码 · 共 27 行

CPP
27
字号
//这个程序在本书所带软盘中,文件名为BREAK.CPP
//这个程序演示中断语句break的应用。

#include <iostream.h>
#include <conio.h>

void main(void)
{
	char text[] = "This is a test string. It contains two setances.";
	int count;

	cout << "最初定义的文字为: " << text << endl;
	for (count = 0; text[count] != '\0'; count++)
	{
		if(text[count] == '.') {
			text[count+1] = '\0';
			break;
		}
	}
	cout << "修改后的文字为: " << text << endl;
}

/*这个程序运行后将输出如下输出结果:
最初定义的文字为: This is a test string. It contains two setances.
修改后的文字为: This is a test string.
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?