English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Consider array of strings with size (i.e. 20,10,30,20)

Find string from above array with start 35 and length 20

Example
Array of strings is = “cat”,”dog”,”mouse”
With start 5 and length 5 result should be “ogmou”

Can be in any language..

2006-09-24 20:44:18 · 4 answers · asked by Inter 1 in Computers & Internet Programming & Design

4 answers

char *ptr;
arr[0]="cat";
arr[1]="dog";
and so on

ptr=arr;
now imagine u got input as 35,20

void myfun(int start,int length)
{
int i=0,j=0;
while(i {
ptr++;
i++;
}

j=start;
while(j {
printf("%c",*ptr);
ptr++;
j++;
}

Since it a contiguous memory allocation(as its an arrangement of arrays it will continue to move 1 byte by byte and will in end print the desired contents

The above program can be improved so dat it does not print '\0' for each string

2006-09-24 21:44:26 · answer #1 · answered by funky_dude 2 · 0 0

The length of the given string as a whole is 20+10+30+20=80
Let us denote this string by s.
in PASCAL language (http://www.freepascal.org)

s=s1+s2+s3+s4+s5;
copy(s, pos("wantedstring",s) ,20);

2006-09-24 21:35:29 · answer #2 · answered by iyiogrenci 6 · 0 0

EVERY question gives 10 points. That's no incentive, and it's completely superfluous to mention it.

Rawlyn.

2006-09-24 21:45:17 · answer #3 · answered by Anonymous · 0 0

i'm not greedy, i don't need 10 points. i will get two, & that's all i need.. =)

2006-09-24 20:45:57 · answer #4 · answered by jv637 5 · 0 1

fedest.com, questions and answers