A
alij
Hi,
I have just started learning C and am working on pointers but am
having difficulty with the following:
If i have a struct, that includes a pointer to char (in my case, i've
named it filename), and in the main code, I want to use that pointer
to create a memory location and assign a character string.
I have gotten the following in the main code (structPtr is a pointer
to they type of struct i have created):
structPtr->filename = malloc(10 * sizeof(char));
How do I give a value, lets stay string value of "cust.txt" to this
field?
Will appreciate any help,
Thanks,
Alij
I have just started learning C and am working on pointers but am
having difficulty with the following:
If i have a struct, that includes a pointer to char (in my case, i've
named it filename), and in the main code, I want to use that pointer
to create a memory location and assign a character string.
I have gotten the following in the main code (structPtr is a pointer
to they type of struct i have created):
structPtr->filename = malloc(10 * sizeof(char));
How do I give a value, lets stay string value of "cust.txt" to this
field?
Will appreciate any help,
Thanks,
Alij