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


Please Help Members By Posting Answers For Below Questions

I want question and paper based MS Projects. Also is there any exam which microsoft conduct for Ms Project professional to issue certification?

2173


Write a function that inserts an integer into a linked list in ascending order. Write the test cases for this function.

5129


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.

2448


Tell about current project ?

2216


Assignment A software house got a project to automate sales/purchase department of a furniture store. The store management is clearly transferred their requirements to the software house management. There is no chance of changing the requirements afterwards. Software house management use waterfall process model to make the project. Given is the progress flow of water-fall process model In waterfall process model, the deliverable (document) produced in one phase serves as an input to the next phase. Suppose you are a project manager who is leading this project. It is decided to work and complete the project using waterfall process model approach. You are required to develop a plan in which the key task is to decide the deliverable that should be built during and after completion of each phase. Also give a description or required contents that must be included in those deliverables. You are not supposed to make the complete project. All you are required to do is to make a Project plan. In that, you need to give a set of deliverables (documents) which according to you, should be developed in each of the phase (Requirements, Designing, implementation, Testing, Maintenance). Also provide contents which should be there in each deliverable. The contents should be clear and have brief explanation. Note:: There are one folder and one file in the attached folder. The file is named as Assignment 4 write-up which is your assignment write-up. The other folder named Project deliverables is the folder in which you are required to organize and place your deliverables. Name of the document/deliverable saved in each folder should be mentioned in the file named checklist (This file is placed in the “Project deliverables” folder) For Example If you produce a deliverable named Requirement Specification (RS) in the “Requirements” phase. You need to do following tasks 1) Finalize the RS contents 2) Save the file in sub-folder named Requirements 3) Write the name of this document in the checklist file under the heading Requirements. Similarly, you need to make and save deliverables of each phase. Not all phases contain one deliverable. There must be some phases having more than one deliverables. PLEASE SIR PRIVIDE ME THE CHECK LIST FOR GIVE SENERION ? CHECKLIST ARE: 1-Requirements 2- Designing 3- Implementation 4- Testing 5- Maintenance

6486






How do you create the Software Project Management Plan (SPMP)?

4043


How do you rate yourself in c#,vb.net,Asp.net,oracle,sql server ?

4974


What training have you undergone in project planning?

3330


What and where are the policy statements for software project planning?

2991


Please, i am a final year student in nigeria and i have a project on pension fund administration and i need help in starting.

1876


Why do you want to work for Microsoft?

2716


create a flow diagram up to 2 levels for hospital management

3226


Test the save dialog in Notepad?

4187


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.

5172


Explain dll hell?

667