i have some general questions about c and memory
if i go
Code:
char *buff = "timmy";
is that a string literal and do string literals and ints go on the memory stack and mallocs on the heap?
ie
Code:
/*stack*/
int i =0;
char* buff = "timmy";
char *ptr = NULL;
/*heap*/
ptr = malloc(sizeof(char)*50);
is the stuff on the stack in ram ?
is the difference between the stack and the heap is that the stack is ordered and heap is potentially fragmented ( sorry but i gotta know )?
last question
when i call a function in main called loadFile
Code:
int main()
{
FILE *fp;
int someInt;
loadFile(fp,"somefile",&someInt);
}
is loadfile now on the stack, and say that loadfile changes the value of fp and someint,
Code:
loadfile(FILE *fp,char *,int * x)
{
*x=5;
...
}
now fp anf someint are also on the stack and the value at that memory location is
changed?