hi guys...bag-o lang ko nagkat-on ug C++. ok ra pagsugod ky naa mn koy background sa C pero pag-abot nkog pointers ug functions ky nagka-saag2 nko... pwede ngau ug tabang ninyo bahin aning butanga?? matsalams!!
hi guys...bag-o lang ko nagkat-on ug C++. ok ra pagsugod ky naa mn koy background sa C pero pag-abot nkog pointers ug functions ky nagka-saag2 nko... pwede ngau ug tabang ninyo bahin aning butanga?? matsalams!!
Pointers are simply pointers to a specified memory address... Example:
int *ptr; // declare an int pointer
int y = 10; // set y initially to 10
ptr = &y; // set the pointer to point to the address (&) of the memory location of y
*ptr = 15; // set the value of the pointed memory (*) to 15.
printf("%d", y); // displays 15.
Pointers are my favorites.
Here are some advantages of using pointers.
1. Can act like returning many values from a function
int i = 1, j = 2, k = 3;
int ret = foo(&i, &j, &k);
// after this line, i is now 10, j = 11, k = 12. and ret = 1
int foo(int *x, int *y, int *z) {
*x = 10;
*y = 11;
*z = 12;
return 1;
}
2. Linked list and dynamic memory allocation
3. Faster.
I prefer using pointers than using array.
Huh? Pointers ug Functions? Murag kuwang rajd kag tuon brader. Dli mana sa C++ ra ang pointers ug functions. Naa pd na sa C. Hell, halos tanan tingai language naay functions.
Basa lng brader. Use Google for your questions. If you get stuck on something specific. Ask here. I'll gladly help. As of now, your question is _very_ broad, makes little sense and you didn't even try to search for answers yourself. A simple Google search on pointers brought me these links.
Have passion for what you do. Programming is a science and like all sciences you have to have a real interest in learning to master it.
waaaaaaaaah!!nakalimot jud kog pangutana ni pareng google tungod sa akong kalibog gahapon...
mao jud bro. pointers ug functions, naa mana both sa C and C++. even if when you said "pointers ug functions" you meant function pointers, still, naa pod na sila both sa C and C++.
Similar Threads |
|