The sample Loadrunner script below shows examples of FOR, DO and DO WHILE LOOPs.

本文通过三种不同的循环结构(FOR循环、WHILE循环及DO-WHILE循环)演示了如何在程序中进行迭代操作。每种循环都实现了从1到10的计数,并通过输出消息显示当前的循环次数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include "as_web.h"

int i;

// Set whileloop = 1 for the while loop example to work
int whileloop = 1;

Action()
{
//Example of a loop using a FOR loop
for (i=1;i<=10;i++)
{
lr_output_message( "FOR Loop number %d", i);
}


//Equivalent example but using a WHILE loop
//This can be made more complicated by including other conditions e.g. &&
i=1;
while ((i <= 10) && (whileloop ==1))
{
lr_output_message( "WHILE Loop number %d", i);
i++;
}


//Equivalent example but using a WHILE loop
//This can also be made more complicated by including other conditions e.g. &&
i=1;
do {
        lr_output_message( "DO WHILE Loop number %d", i);
i++;
}
while (i <= 10) ;


return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值