Hey guys,
Today's class seemed a little confusing to some.
Basically what he was saying is when your casting just take the type and put that in front of the pointer. Here's a simple example...
double example1(int, int, double);
int main()
{
/* Create pointer to a void type */
void (*p);
double holder = 0;
/*Cast pointer of void type to function type wanted */
p = (*(double (*)(int, int, double))p);
/*Let pointer be pointed to function start */
p = example1;
/*Run pointer and hold returned value */
holder = *p(2, 4, 5);
}
Wednesday, June 9, 2010
Thursday, June 3, 2010
Strings strings strings
Hey guys,
Todays class was interesting to say the least for the tangent Fardad went off on strings.
Basically:
char hello[50] = "hello everyones, how's it going"
where, the variable hello is compatible to the string "hello everyones, how's it going"
so that you can actually do the following:
printf("%c", "hello everyones, how's it going"[5]);
which is the same as,
printf("%c", hello[5]);
The string you put the variable equal are identical to each other in the usage aspect.
Subscribe to:
Posts (Atom)