how to use a *
in a function
the operator's function / * -> * / are she/it is useful for structures to affect by a *
if yes how to use him correctly
how to use a *
in a function
the operator's function / * -> * / are she/it is useful for structures to affect by a *
if yes how to use him correctly
The above code is a very small sample using a char* for a parameter in a function. Take the above and modify it to see if you can use arrays for parameters or pass an array to the function above - any which way you choose.Code:void printString(char *strVal) { printf("This function printed the parameter char* strVal: %s", strVal); } int main (void) { strTest = "Let us see if this string gets printed."; printString(strTest); return 0; }
what about "->"
-> is for a pointer to a structure. Here is an example:
Code:#include <stdio.h> struct myStruct { int value; }; void foo(struct myStruct *mine) { mine->value = 11; } int main(void) { struct myStruct bar; foo(&bar); printf ("%d\n", bar.value); return(0); }
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]