below are various types of string functions which are used in Load Runner
1) Strlen();
2) strcpy();
3) strcat();
4) strcmp()
5) stricmp()
6) Strncmp();
7) Sprintf();
8) Strtok();
9) Conversion Functions
STRLEN();
This Function is used find the length of a given string.
Action()
{
int a,b;
char *temp ="Welcome To Load Runner";
a=strlen("Welcome To Load Runner");
b=strlen(temp);
lr_output_message("%d",&a);
lr_output_message("%d",&b);
return 0;
}
STRCPY();
This Function used to copy the whole string into another string
1) By storing the value in to another variable
Action()
{
char temp2[100];
char *temp1 ="Welcome To Load Runner";
strcpy(temp2,temp1);
lr_output_message("%s",temp1);
lr_output_message("%s",temp2);
return 0;
}
with out storing the value in to another variable
Action()
{
char temp2[100];
char *temp1 ="Welcome To Load Runner";
strcpy(temp2,temp1);
lr_output_message("%s",temp1);
lr_output_message("%s",temp2);
return 0;
}
STRCAT();
This function is used to concatenates two strings,the second string will appended to first string.
Action()
{
char temp[100];
strcpy(temp,"welcome to load runner");
strcat(temp,"performance tool");
lr_output_message("%s",temp);
return 0;
}
STRTOK();
This is function is used to split the string to into no.of sub strings using a common deliminator or separator.
Action()
{
char *temp2[]="welcome to load runner";
char *token;
token=(char *)strtok(temp2," ");
while(token!=NULL)
{
lr_output_message("%s",token);
token=(char *)strtok(NULL,"");
}
return 0;
}
STRCMP();
This function is used to compare the strings,strings will be compared based on their ASCII values and
-> If both the strings are equal then it returns 0;
-> If first string is greater then the second string then it will returns 1
-> If second string is greater then the first string then it will returns -1
Action()
{
int a,b,c;
a=strcmp(Hyderabad,Bangalore);
b=strcmp(Hyderabad,Hangalore);
c=strcmp(Hyderabad,Hyderabad);
lr_output_message("%d",&a);
lr_output_message("%d",&b);
lr_output_message("%d",&c);
return 0;
}
STRICMP();
This function is used to ignore the cases and treats the upper case and lower case letters same.
Action()
{
int a;
a=stricmp(Hyderabad,HYDERBAD);
lr_output_message("%d",&a);
return 0;
}
STRNCMP();
This function will compare the strings and if they are not equal then it will returns ASCII code deference value between them.
Action()
{
int a;
a=strncmp(Hyderabad,HYDERBAD);
lr_output_message("%d",&a);
return 0;
}
A To F:
This function is used to Converts a string formatted float value into Float value.
A To F:
This function is used to Converts a string formatted Long value into Long value.
1) Strlen();
2) strcpy();
3) strcat();
4) strcmp()
5) stricmp()
6) Strncmp();
7) Sprintf();
8) Strtok();
9) Conversion Functions
STRLEN();
This Function is used find the length of a given string.
Action()
{
int a,b;
char *temp ="Welcome To Load Runner";
a=strlen("Welcome To Load Runner");
b=strlen(temp);
lr_output_message("%d",&a);
lr_output_message("%d",&b);
return 0;
}
STRCPY();
This Function used to copy the whole string into another string
1) By storing the value in to another variable
Action()
{
char temp2[100];
char *temp1 ="Welcome To Load Runner";
strcpy(temp2,temp1);
lr_output_message("%s",temp1);
lr_output_message("%s",temp2);
return 0;
}
with out storing the value in to another variable
Action()
{
char temp2[100];
char *temp1 ="Welcome To Load Runner";
strcpy(temp2,temp1);
lr_output_message("%s",temp1);
lr_output_message("%s",temp2);
return 0;
}
STRCAT();
This function is used to concatenates two strings,the second string will appended to first string.
Action()
{
char temp[100];
strcpy(temp,"welcome to load runner");
strcat(temp,"performance tool");
lr_output_message("%s",temp);
return 0;
}
Action()
{
char temp3[100];
char *temp1="welcome to load runner";
char *temp2='Performance Tool';
strcat(temp3,temp1);
strcat(temp3,temp2);
lr_output_message("%s",temp3);
return 0;
}
{
char temp3[100];
char *temp1="welcome to load runner";
char *temp2='Performance Tool';
strcat(temp3,temp1);
strcat(temp3,temp2);
lr_output_message("%s",temp3);
return 0;
}
This is function is used to split the string to into no.of sub strings using a common deliminator or separator.
Action()
{
char *temp2[]="welcome to load runner";
char *token;
token=(char *)strtok(temp2," ");
while(token!=NULL)
{
lr_output_message("%s",token);
token=(char *)strtok(NULL,"");
}
return 0;
}
STRCMP();
This function is used to compare the strings,strings will be compared based on their ASCII values and
-> If both the strings are equal then it returns 0;
-> If first string is greater then the second string then it will returns 1
-> If second string is greater then the first string then it will returns -1
Action()
{
int a,b,c;
a=strcmp(Hyderabad,Bangalore);
b=strcmp(Hyderabad,Hangalore);
c=strcmp(Hyderabad,Hyderabad);
lr_output_message("%d",&a);
lr_output_message("%d",&b);
lr_output_message("%d",&c);
return 0;
}
STRICMP();
This function is used to ignore the cases and treats the upper case and lower case letters same.
Action()
{
int a;
a=stricmp(Hyderabad,HYDERBAD);
lr_output_message("%d",&a);
return 0;
}
STRNCMP();
This function will compare the strings and if they are not equal then it will returns ASCII code deference value between them.
Action()
{
int a;
a=strncmp(Hyderabad,HYDERBAD);
lr_output_message("%d",&a);
return 0;
}
SPRINTF();
This function is used to print and save any given formatted data into a string variable.
Action()
{
char a[100];
sprintf(a,"%s","welcome to load runner");
lr_output_message("%s",&a);
return 0;
}
Conversion Functions:
A To I:
This function is used to Converts a string formatted integer value into pure integer value.
I TO A
{
char a[100];
sprintf(a,"%s","welcome to load runner");
lr_output_message("%s",&a);
return 0;
}
Conversion Functions:
A To I:
This function is used to Converts a string formatted integer value into pure integer value.
I TO A
This function is used to Converts a integer formatted string value into pure string value.
A To F:
This function is used to Converts a string formatted float value into Float value.
A To F:
This function is used to Converts a string formatted Long value into Long value.
No comments:
Post a Comment