![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pass a pointer-to-pointer, or return a pointer? | aaronwong | High Level Programming | 11 | 01-08-2009 01:03 PM |
| New Assignment | vakharia Mahesh | What's on Your Mind? | 3 | 12-02-2007 04:07 PM |
| how to do my assignment????? | amelia | UNIX for Dummies Questions & Answers | 1 | 01-19-2006 11:17 AM |
| @ in a variable assignment | rkap | UNIX for Dummies Questions & Answers | 1 | 05-23-2005 10:53 AM |
| awk - value assignment. | videsh77 | Shell Programming and Scripting | 2 | 12-31-2004 05:38 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
The pointer number is undefined. You could do this, however:
int numberStorage; int *number = &numberStorage; *number = 4; That example basically sets numberStorage to 4. The string example is okay because the double quotes allocate static storage automatically. Julian |
|
||||
|
broli,
C does not hide memory pointer information. "asdf" is a "string literal." when initializing a char*, "asdf" is seen by the program as a pointer to that location in memory. The same is not true for other basic types. int *Bogus = { 0, 1, 2, 3, 4}; - does not work int Correct[5] = { 0, 1, 2, 3, 4}; does work malloc() allocates memory on a global heap, and requires a type cast. using [] allocates memory locally, and the size of this chunk is limited, so don't use brackets for really big arrays. Two operators will come in handy all the time... "*" and "&" |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|