Skip to main content

Strtok Function in Loadrunner with Example

Sometimes we want to capture all the values that match our specified delimiters and conditions but strtok function itself only captures the current value in the char token. Adding a sprintf function will allow you to store each of the values that you want to capture for later use (like choosing random) in different parameters.

Below is the code:

getMultipleValues(char *Chain){
    char separators[] = ":,";
    char * token, tempvalue [100];
    int i;
    extern char * strtok(char * stringconst char * delimiters );
    token = (char *)strtok(Chain, separators);
    while (token != NULL ) {

            token = (char *)strtok(NULL, separators);
        token = (char *)strtok(NULL, separators);

Where you call the function: getMultipleValues(lr_eval_string("{ParamName}"));

Assuming the string Items{“ID”:29990, “Name”: TestName1, “OtherArguments”:Test1}{“ID”:29991, “Name”: TestName2, “OtherArguments”:Test2}{“ID”:29992, “Name”: TestName3, “OtherArguments”:Test3}
The output would be:
ProjectId_0 = 29990
ProjectId_1 = 29991

ProjectId_2 = 29992


Popular posts from this blog

File operations in loadrunner with examples

In this post I will explain how to capture a value from server response and save to a text file using vugen. How to capture and save to text file using loadrunner: First I have recorded the script using and then i searched for IBM. We will get 10 results. I have captured all the 10 values and saved to a file. Here is the code for that.

NeoLoad Interview Questions and Answers

Here are some of the interview questions and answers on NeoLoad: What is NeoLoad? NeoLoad is a performance testing tool designed to test different types of web, standalone and mobile applications. What is the difference between Loadrunner, JMeter and NeoLoad? Click here for differences What are the different counters you monitor in NeoLoad? Average Response Time(requests), average response time(pages), average requests/s, average throughput, current response time(requests), current response time(pages), current requests, current throughput, current users count, controller cpu load, controller memory load etc. What are the different type of tools you can integrate with NeoLoad? App Dynamics, CA APM Integration, Dyna trace integration, HP ALM or Quality Center Integration, Java and Jamo Solutions M-eux Test Integration, Jenkins Integration, perfecto mobile integration, selenium integration. What are the different type of Operating systems you can mon