Write the InStr function. Write the test cases for this
function?
Answer Posted / majhoul
int Instr(int start,string string1,string string2,string type-of-the-test)
{
lenght= string2.lenght();
int lenght ;
int i ;// as counter for lenght
if (string1==NULL ll string2==Null)// to check that the
both of the strings
is not empty
return 0;
if (type-of-the-test = "text")// it doesn't matter if it is upper or lower case in the text test !!!
{
string1=toupper(string1) ;
string2=toupper(string2) ;
}
int location = string1.find(string2);
while (location != string::npos)//
{
if (location > start) // the string was found we have to check if it is match the type the test
{
i=0 ;
while ( lenght > 0 )
{
if (string1[location+i]!= string2[i] )
break ;// return where the string was found
}
if ((lenght-1) == i)
return location ;
}
else
location = string1.find(string2,location+1)
}
return 0 ; // if the string wasn't find at all [p
}
' String to search in.
string SearchString = "XXpXXpXXPXXP"
string SearchChar = "P"
TestPos = InStr(4, SearchString, SearchChar,"Text")
' A binary comparison starting at position 1. Returns 9.
TestPos = InStr(1, SearchString, SearchChar,"binary")
//' If Option Compare is not set, or set to Binary, return //9.
//' If Option Compare is set to Text, returns 3.
//TestPos = InStr(SearchString, SearchChar)
//' Returns 0.
//TestPos = InStr(1, SearchString, "W")
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Write the instr function.
Explain the various activities you do (as a PL) when the project is started up.
Tell about yourself and job ?
What is the project management structure in your project? Is a PL assigned to the project?
How would you deal with a bug that no one wants to fix? Both the SDE and his lead have said they won?t fix it?
What is the role of CLR in ASP.NET?
Tell about current project ?
Why do you want to work for Microsoft?
how to tell project details in interview the project is funds flow analysis?
funds flows analysis how to prepare for interview
Can any one please give me an effective format for designing a functional specification and technical specification sheet for a software developemnt related company asap...it would be highly useful for my final year project.
How did you choose the appropriate lifecycle for your project?
What training have you undergone in project planning?
Given a MAKEFILE (yeah a makefile), design the data structure that a parser would create and then write code that iterates over that data structure executing commands if needed.
create a flow diagram up to 2 levels for hospital management