| | |
The * in a function.
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Pointer syntax in C/C++ is very flexible, but likewise very confusing. You can say something like
but this should be read carefully as
:an integer, a pointer to an integer, and a pointer to a pointer to an integer. Yeah, I know... read it again anyway... (I attached the "*" to the int because it is part of the type of each variable, but it could be anywhere between the base type and the variable name.)
In C, you are forgiven a lot when dealing with the type of things. Hence, as already mentioned, the variable
However, you can't use the [] brackets when declaring a function return type, so you are stuck with the *.
Hope this helps.
int i, *pi, **ppi;but this should be read carefully as
int i;
int* pi;
int** ppi;:an integer, a pointer to an integer, and a pointer to a pointer to an integer. Yeah, I know... read it again anyway... (I attached the "*" to the int because it is part of the type of each variable, but it could be anywhere between the base type and the variable name.)
In C, you are forgiven a lot when dealing with the type of things. Hence, as already mentioned, the variable
int* pi can be a pointer to a single integer or a pointer to a whole lot of them. Typically, programmers will state their intent by saying eitherint *a --pointer to a single int, orint a[] --pointer to an array of ints.However, you can't use the [] brackets when declaring a function return type, so you are stuck with the *.
Hope this helps.
Last edited by Duoas; Oct 27th, 2007 at 12:42 am.
![]() |
Similar Threads
- Need help on a program (function bug) (C)
- Assign content to a function pointer (C)
- PHP Feezing with a function (PHP)
- ASP Replace Function.... (ASP)
- missing function header (C++)
- Function that returns void (C++)
Other Threads in the C++ Forum
- Previous Thread: learning WIN32 GDI
- Next Thread: Whats the difference between...plz respond in the next 5-10min
Views: 595 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






