goto 语句的使用(1)
2010-07-31 09:22
211 查看
// wula.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <malloc.h>
void TestFunction();
int main(int argc, char* argv[])
{
TestFunction();
return 0;
}
void TestFunction()
{
bool bContinue = false;
bool bBreak = false;
char *pBuffer = NULL;
while (1)
{
pBuffer = (char*)malloc(1000);
if (bContinue)
{
goto TestFunction_Continue_Loop;
}
if (bBreak)
{
goto TestFunction_End_Loop;
}
TestFunction_Continue_Loop:
free(pBuffer);
pBuffer = NULL;
}
TestFunction_End_Loop:
if (pBuffer != NULL)
{
free(pBuffer);
pBuffer = NULL;
}
return;
}
//
#include "stdafx.h"
#include <malloc.h>
void TestFunction();
int main(int argc, char* argv[])
{
TestFunction();
return 0;
}
void TestFunction()
{
bool bContinue = false;
bool bBreak = false;
char *pBuffer = NULL;
while (1)
{
pBuffer = (char*)malloc(1000);
if (bContinue)
{
goto TestFunction_Continue_Loop;
}
if (bBreak)
{
goto TestFunction_End_Loop;
}
TestFunction_Continue_Loop:
free(pBuffer);
pBuffer = NULL;
}
TestFunction_End_Loop:
if (pBuffer != NULL)
{
free(pBuffer);
pBuffer = NULL;
}
return;
}
相关文章推荐
- 为什么使用goto语句作错误处理 by明智
- 用户登录的模拟 goto语句的使用
- 为什么使用goto语句作错误处理
- 语言中break,continue和goto语句的使用
- 为什么使用goto语句作错误处理
- PHP goto语句简介和使用实例
- goto 语句(虽然不提倡使用goto 但是比赛的时候还蛮好用滴)
- 为什么使用goto语句作错误处理
- 丶使用goto语句在数组中搜索指定图书
- C语言字符串匹配、goto语句、关机命令使用
- golang跳转语句goto,break,continue的使用及区别
- 在程序中,你敢怎样使用“goto”语句!
- 21、goto语句的使用
- 为什么使用goto语句作错误处理
- [编程好习惯] 恰当使用goto语句
- 使用goto语句构成的循环求1~100之间的所有奇数之和,即求解表达式1+3+5+...+99之和。
- 为什么使用goto语句作错误处理
- 避免使用goto语句的几种方法
- 为什么使用goto语句作错误处理
- c#中为什么又重新使用了goto语句