Hello!
I'm doing homework for university in C
I have actually finished it, but i have some questions.....
[already having problems expressing myself]
[i will generalize]
Is that correct (well it works)?
now i want to do the same, but this time i don't want create to return anything, i want it to work directly with pointer (if what i say makes sense)
can someone, plz, show me example how to do that?
EDIT:
I've just read another article....
Ok, i want to make it clear
I want a variable (or pointer)
then with create allocate memory and assign it to variable (pointer?)
i will later use that variable (pointer?) for other stuff to refer to allocated memory
I'm doing homework for university in C
I have actually finished it, but i have some questions.....
[already having problems expressing myself]
[i will generalize]
Code:
#include <stdlib.h>
void *create(void);
int main()
{
unsigned char *ptr; /* my pinter, that will point to arry of text (unsigned char */
ptr=create(); /* allocate memory */
}
void *create(void)
{
unsigned char *new_ptr;
new_ptr=malloc(1000);
...
return new_ptr;
}
Is that correct (well it works)?
now i want to do the same, but this time i don't want create to return anything, i want it to work directly with pointer (if what i say makes sense)
can someone, plz, show me example how to do that?
EDIT:
I've just read another article....
Ok, i want to make it clear
I want a variable (or pointer)
then with create allocate memory and assign it to variable (pointer?)
i will later use that variable (pointer?) for other stuff to refer to allocated memory