I have one pointer and one pointer array, both of char type. I have read all elements of a file into the pointer, character by character. The elements of the file contain spaces, dots, commas etc. I want to filter out the punctuations and transfer ONLY the words into the pointer array.
This is the first part of my code:-
This correctly assigns all elements of the file(which contains a paragraph with word,sentences,puncs etc). Now I have this pointer array:-
I have assigned each element of the pointer array with a memory space of 30 bytes.
Now, I have an if loop which should filter out the punctuations from the ptr pointer and put only the words into the string array pointer..and each word should be stored at a diff location i.e
string should be "The", string should be "highlands" etc.
This is my loop for trying to incorporate the above functionality:-
if((ptr[j])==' ' || ptr[j]!='.' || ptr [j]!='!' || ptr[j]!=',')
string[k]= &(ptr[j]);// I have tried it with and without the address '&' operator but to no avail
The above code assigns the entire para to the pointer array, without ignoring the spaces, commas or full stops. When I print the first element string..it prints the entire paragraph. string also prints the entire thing but starting from the fifth character. Whats gone wrong? Help please.