so I have a function that takes a Pointer to an array of 'Strings' (I understand strings as just blocks of memory that is followed by '\0'). Since a string is already a pointer to the first byte of a string, my pointer is actually a ** doublePointer. However I am seg-faulting off the Ying Yang and I honestly dont know what is going on in the low level view. Here is my code below, its function is to read characters and capitalize the first letter of the first word (in string) and after a period.
void autocaps(char ** words)
{
/* Add code here */
//Period Boolean
bool next=false;
//First Word Boolean
bool fcap=true;
//Counter Variable
int i=0;
int j=0;
//Second Pointer
char** wordx = words;
//LowerCase Bomb & Period Flagging
while(wordx[i][j]!='\0'){
while(wordx[i][j]!='\0'){
//A-Z Filter
if((wordx[i][j]>='A')&&(wordx[i][j]<='Z')){
wordx[i][j]+=32;
}
if(wordx[i][j]=='.'){
next=true;
}
j++;
}
i++;
}
i=0;
j=0;
//Cap First Word & Cap Post Period
while(words[i]!='\0'){
while(words[i][j]!='\0'){
//a-z Filter
if((words[i][j]>=97)&&(words[i][j]<=122)){
if(fcap){
words[i][j]-=32;
fcap=false;
}
if(next){
words[i][j]-=32;
}
}
j++;
}
i++;
}
return;
}
I am seg-faulting when I am printing the original pointer that was passed through the parameter. If someone could explain to me the low level concept of this because I am so confused I am throwing triple and quadruple stars in everywhere and I dont even know if it brings me closer or farther from debugging my code.
Thank You!!