0

I need to write a function that will take a string and an int and return the string from index int onward.
for ex

Line = "Enter a line: ";
WriteString(RetStr(Line,4 ));
//Should return   er a line:

AnsiString RetStr(AnsiString Str, int Start)
{     int ill;
      ill=1;
      char temp;
      while (Start!=Length(Str))
      {
           temp=Str[Start];
           Str[ill]=temp;
           ill=ill+1;
           Start=Start+1;  
       }
                return Str;
}

I've tried it in several combinations like trying to use a for loop but Str[ill]=Str[Start+1] gives some errors that i don't know what to make of them.
Please help...
Any pointers will be greatly appreciated

4
Contributors
3
Replies
4
Views
11 Years
Discussion Span
Last Post by ivanCeras
0
string str1="Function for a string";
string str2=str1.substr(9);
cout<<str2;
0
char string[80];
int index;
 
 
printf("Enter a string:");
scanf("%s",&string);
 
START:
printf("where to start display");
scanf("%d",&index);
 
if(index<strlen(string)){
goto START;
}
 
y=0;
for(x=index ; x< strlen(string);x++){
buffer[y] = string[x];
y++;
}
 
 
printf("%s",&buffer);
getch();

<<email snipped>>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.