I got the first part but i tried everything on the second part. nothing work. please help!!
Code:
else if (choice == 3)
{
cin.ignore();
cout<<"How many characters from the beginning of the string do you want to display? ";
cin>>begin_display;
if (strlen(str) < begin_display)
printf("Error: too many characters.\n");
else
{
choicethree(str, begin_display);
printf("%s\n",str);
}
}
else if (choice == 4)
{
cin.ignore();
cout<<"How many characters from the end of the string do you want to display? ";
cin>>end_display;
if (strlen(str) < end_display)
printf("Error: too many characters.\n");
else
{
choicefour(str, end_display);
printf("%s\n",str);
}
}
void choicethree(char str[], int begin_display)
{
for (int n = begin_display ; n < strlen(str); n++)
{
str[n] = '\0';
}
}
void choicefour(char str[], int end_display)
{
int left;
left = strlen(str) - end_display;
for (int i = 0; i < (strlen(str) - end_display) ; i++)
{
str[i] = '\0';
}
}