Hi,
I am working on a project where I need to use a structure. Here is the layout of the structure and the type I defined for it.
The program I am working on is supposed to prompt the user for input, read and tokenize their input and store data in the structure, the user must enter "exit" to terminate the program. At the end I have to print the structure: so on an inputCode:struct PARAM
{
char *InputRedirect; /* file name or NULL */
char *OutputRedirect; /* file name or NULL */
int Background; /* either 0 (false) or 1 (true) */
int ArgumentCount; /* same as argc in main() */
char *ArgumentVector[MAXARGS]; /* array of strings */
};
/* define a struct type named Param_t */
typedef struct PARAM Param_t;
/* allocate space for the struct */
Param_t *p = (Param_t *) malloc(sizeof(Param_t));
"Hello My Name is Hunter"
I should see:
ArgumentVector[0] = Hello
ArgumentVector[1] = My
ArgumentVector[2] = Name
ArgumentVector[3] = is
ArgumentVector[4] = Hunter
but for some reason the "exit" string i type to terminate the program is overwriting ArgumentVector[0].
I am new to C (coming from Java) Any help would be great?
Thanks,
Hunter