- Nov 9, 2011
- 355
- 0
- 0
Hi guys, I'm having trouble with a couple problems in C. I am newish to C as I have taken several classes on Java, but C is a lot different in passing by value.
Anyway here is what I have. The homework assignment is a pre-written shell that I need to modify to do things. Anyway...
void eval(char *cmdline) //This is fine
{
char array[MAXLINE];
array[0] = *cmdline;
if(parseline(*cmdline, *array)== 1) //This is the problem
}
int parseline(const char *cmdline, char **argv) //This is fine
I have a terrible time with pointers in C, I get extremely confused by them.
The first argument parseline takes is a pointer, which I am passing it. The second argument it takes is a pointer to a pointer, and I don't know what to pass it. Do I need to make another local variable in eval that points to array and then point to that?
Like
char *newArray = &array; ????
Anyway here is what I have. The homework assignment is a pre-written shell that I need to modify to do things. Anyway...
void eval(char *cmdline) //This is fine
{
char array[MAXLINE];
array[0] = *cmdline;
if(parseline(*cmdline, *array)== 1) //This is the problem
}
int parseline(const char *cmdline, char **argv) //This is fine
I have a terrible time with pointers in C, I get extremely confused by them.
The first argument parseline takes is a pointer, which I am passing it. The second argument it takes is a pointer to a pointer, and I don't know what to pass it. Do I need to make another local variable in eval that points to array and then point to that?
Like
char *newArray = &array; ????
Last edited:
