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

Member Avatar for iamthwee

substring() perhaps?

string str1="Function for a string";
string str2=str1.substr(9);
cout<<str2;
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>>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.