strArray was declared as :
Code:
char **strArray = NULL;
It is supposed to be an array of strings. I probably don't have to tell you this is my first time messing with those. I've used two dimensional arrays, but always of a constant size. I.e. I knew the size when writing the program.
Basically, I'm having problems with the array going between functions. I.e. in the FillArray function it's working properly. I'm filling each element of the array one by one in the for loop, and prints it out afterwards. However, as soon as I leave that loop, it's not acting normally. I.e. initially it prints as such :
Code:
palindromes
String manipulation and recursion
Otto
Command-line arguments
Anna
file handling and dynamic memory allocation
Able was I ere I saw Elba
ctype.h
Madam, I'm Adam.
Use of menus: Integer vs. Character input
Array of strings?
Looking for EOF?
Was it a cat I saw?
A man, a plan, a cat, a canal: Panama?
But when I print it in the exact same manner in the next function, MenuOne it prints as such:
Code:
pSOCAfAcMUALWA man, a plan, a cat, a canal: Panama?
SOCAfAcMUALWA man, a plan, a cat, a canal: Panama?
OCAfAcMUALWA man, a plan, a cat, a canal: Panama?
CAfAcMUALWA man, a plan, a cat, a canal: Panama?
AfAcMUALWA man, a plan, a cat, a canal: Panama?
fAcMUALWA man, a plan, a cat, a canal: Panama?
AcMUALWA man, a plan, a cat, a canal: Panama?
cMUALWA man, a plan, a cat, a canal: Panama?
MUALWA man, a plan, a cat, a canal: Panama?
UALWA man, a plan, a cat, a canal: Panama?
ALWA man, a plan, a cat, a canal: Panama?
LWA man, a plan, a cat, a canal: Panama?
WA man, a plan, a cat, a canal: Panama?
A man, a plan, a cat, a canal: Panama?
My function call for MenuOne is :
Code:
MenuOne ( counter, strArray );
And its prototype is as follows, and it's printed out as such :
Code:
void MenuOne ( int numStrings, char *strArray )
for ( i = 0; i < numStrings; i++ )
{
printf( " %s\n", &strArray[i] );
}