So I got an error that was along the lines of "Error while dumping state (probably corrupted stack) Line 51: 204 Segmentation fault". I have looked at line 51 and it is actually a blank line. So the segmentation fault must occur before that, anyway I am a student and still am not too great at finding these types of errors. Someone please help and take a look and I'm open for criticism in order to make my coding more simple (as long as they follow my instructions) (no vectors and it must be a string of pointers). Thank you


CODE:

#include <stdlib.h>
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

char all(char** first);
char reverse(char** first);
char backward(char** first);
char firstletter(char** first);
char third(char** first);
char lengths(char** first);
char ei(char** first);

int main(){

char** first;
first = new char*[5];
first[0] = "boat";
first[1] = "goat";
first[2] = "gray";
first[3] = "mind";
first[4] = "soul";

all(first);
reverse(first);
backward(first);
firstletter(first);
third(first);
lengths(first);
ei(first);

delete first[5];

return (EXIT_SUCCESS);
}

//Display all the strings from both arrays.
char all(char *first[]){

cout << "List of all words:" << endl;

//pointer array
for(int i=0; i<5; i++)
cout << *(first + i) << endl;

return 0;
}


//Display the strings in reverse order.
char reverse(char *first[]){

cout << "\nList of all words in reverse order:" << endl;

//pointer array
for(int i=4; i>=0; i--)
cout << *(first + i) << endl;

return 0;
}

//Display the strings backwards. OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
char backward(char *first[]){

char *p;
cout << "\nList of all words backwards:" << endl;

for(int i=0; i<5; i++){
p = first[i];
for(int j=3; j>=0;j--)
cout << p[j];
cout << endl;
}
return 0;
}

//Display the first letter of each string.
char firstletter(char *first[]){

cout << "\nList of all words' first letters:" << endl;

//pointer array
for(int i=0; i<5; i++)
cout << *first[i] << endl;

return 0;
}

//Display each string from the third letter to the end of the string.
char third(char *first[]){

char *p;
cout << "\nList of all words starting from the third letter:" << endl;

for(int i=0; i<5; i++){
p = first[i];
for(int j=3; j<4; j++)
cout << p[j];
cout << endl;
}
return 0;
}

//Display the length of each string.
char lengths(char *first[]){

string word;

cout << "\nThe length of each word is :" << endl;

for(int i=0; i<5; i++){
word = first[i];
cout << word.length() << endl;
}
}

//Display strings with "e" or "i"
char ei(char *first[]){

cout << "\nThe words that contain 'e' and 'i' are:" << endl;

for(int x=0; x<5; x++){

char* token_e = strtok(first[x], "e");
char* token_i = strtok(first[x], "i");

if((token_e != NULL)||(token_i != NULL))
cout << "'e' or 'i' was not located in this word." << endl;
}

return 0;
}