There are quite a few problems with your code, but only 2 main ones. I'm
1. pointerMan is not initialised and you try to access it in function cat() on first iteration to look for '\0' even though the storage slot is empty...
2. Stuff is far too complicated for this task.
3. I think you mean sentence, rather than sentences.
4. Condition
*tmp != '\0'
needs to be at line 21, when the user enters 0. You're needleslly calling cat.
I don't understand line 23 and 22. You're trying to save multiple sentences into arrayMan? Don't use &, just correct line 22 to
arrayMan[count++] = pointerMan;
. Fix cat first, and simplify it by renaming it to reverse.
Scrap everything. Read this pseudo code and start from there.
Edit: sorry, misread your code. I'm not used to seeing global variables and static allocation.
char **sentences = alloc
loop
readline
exit if input = 0
data = reverse(input)
print data
sentences[n++] = data /* delete this later on */
end loop
reverse (string)
create temp [char *]
temp += strlen(string)
*temp = '\0'
while (*string)
*temp-- = *string++;
return temp
end
|