General C Programming Examples

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

GENERAL C PROGRAMMING EXAMPLES

TABLE OF CONTENTS

INTRODUCTION

1. PROGRAM FORMAT

C PROGRAM FORMAT

USER-DEFINED FUNCTIONS IN C

LOADRUNNER SCRIPTS AND C

2. DATA TYPES

INTEGER TYPE

FLOAT TYPE

CHAR TYPE

FORMAT CONTROL

EXERCISE 2.1

3. CONTROL FLOW

BOOLEAN OPERATORS

IF STATEMENTS

SWITCH STATEMENT

EXERCISE 3.1

FOR LOOPS

WHILE

DO WHILE

BREAK AND CONTINUE

EXERCISE 3.2

THE ? OPERATOR

4. ARRAYS AND STRINGS

ARRAYS

STRINGS

EXERCISE 4.1

STRING MANIPULATION

MULTI-DIMENSIONAL ARRAYS

5. FILE PROCESSING

FILE DECLARATION

FILE OPENING

FILE READING

EXERCISE 5.1

FILE WRITING

EXERCISE 5.2

6.FUNCTIONS

USER-DEFINED FUNCTIONS EXERCISE 6.1

INCLUDE FILES

EXERCISE 6.2

7. MISCELLANEOUS FUNCTIONS SY STEM

RANDOM NUMBERS SOLUTIONS

EXERCISE 2.1

EXERCISE 3.1

EXERCISE 3.2

EXERCISE 4.1

EXERCISE 5.1

EXERCISE 5.2

EXERCISE 6.1

Introduction

My initial plan was to create a C reference manual for the Mercury Test Team. This is because LoadRunner scripts consist of calls to LoadRunner functions, which are essentially C function libraries. Since C forms the basis for LoadRunner scripts, most of the functions in C are supported in LoadRunner. Expertise in C will help you customize and improve the scripts greatly. So we thought that a C reference manual would be very useful.

Though LoadRunner is based on C, there are a few variations and exceptions to the C functions that are supported in LoadRunner. Moreover, I did not want to add the overhead of owning a C compiler to go through the exercises in this manual. So I thought I‟d create a manual that would work wi th Virtual User Generator (Vugen). I am hoping that by the time you get to this manual, you are already familiar with the components of LoadRunner.

All exercises in this manual can be compiled and run in Vugen. As I discuss each topic in C, I‟ll also di scuss how it differs in LoadRunner and the context in which this function might be useful. This will both familiarize you with C from a LoadRunner perspective, and make you comfortable with using custom coding in LoadRunner.

If you are already comfortable with C, you might be able to skim through this manual in no time. Please note that the purpose of this manual is not to make a C expert out of you; most of the concepts and exercises in here are very elementary. This will just be a quick C/LoadRunner reference.

Hope you find this work useful.

相关文档
最新文档