I have two quick problems with the code I am writing:
First, I define a struct of char arrays (strings) and then try accessing the same. I get an "incompatib le types in assignment" error:
.
The second question I think has to do with a pointer issue, but I'm not sure.
.
When I run it, I get a "Passing arg 1 of 'atoi' makes pointer from interger without a cast" and I get the same error for arg 2 of strcpy.
Please help, and thanks in advance.
First, I define a struct of char arrays (strings) and then try accessing the same. I get an "incompatib le types in assignment" error:
Code:
struct {
char name[50];
char value[50];
} varlist[20];
int main(int argc, char *argv[]) {
varlist[0].name = "foo";
varlist[0].value = "bar";
}
The second question I think has to do with a pointer issue, but I'm not sure.
Code:
char *mymethod(char str[]){
char *result = malloc(100*sizeof(char));
strcpy(result, atoi(global_variable));
// global_variable is defined in a header file
return result;
}
When I run it, I get a "Passing arg 1 of 'atoi' makes pointer from interger without a cast" and I get the same error for arg 2 of strcpy.
Please help, and thanks in advance.
Comment