KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I know for sure that function(int *a); function(int a[]); in C are the same, function(int a[]) will be translated into function(int *a) int *a = malloc(20); int b[] = {1,2,3,4,5}; These two are not the same, the first is a pointer, the second is an array. What happens when I call function(b)?(function(int *a)) I know that b is on the stack, so how is passed to that function? Secondly, strings: char *c1 = "string"; char c2 [] = "string"; In this case I don't know where is c1, and I suppose that c2 is on the stack. Suppose that function now is: function(char *c), which is the same as function(char c[]), what happens when I call function(c1), and function(c2), the strings will be passed by reference or value?
Tags (comma-separated)
Save Edits
Cancel