| | |
simple project to help me understand pointers.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 7
Reputation:
Solved Threads: 0
Hey guys, I "understand" pointers. But I do not understand how I could actually put them to use. If you could give me a few example programs of how they would be used, then I could try to make the programs. I don't want the code, just the logic behind the program. I don't someone to just hand me over the answer, it will be much more rewarding if I can figure it out on my own.
Thanks,
Joe
Thanks,
Joe
There are millions of examples because they are frequently used in every-day applications. But a simple introduction might be to write a function that sets all the bytes of a character array to 0. Function prototype might be
C++ Syntax (Toggle Plain Text)
void clear_array(char* array, int size);
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Sample code
c++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main() { int x; // A normal integer int *p; // A pointer to an integer p = &x; // Read it, "assign the address of x to p" cin>> x; // Put a value in x, we could also use *p here cin.ignore(); cout<< *p <<"\n"; // Note the use of the * to get the value cin.get(); }
![]() |
Similar Threads
- Pointers (archived tutorial) (C++)
- What relation does **indirection operator have with Multidimensional Arrays (C++)
- Problem of sorting words of each string using pointers (C++)
- Not home work help but very ver simple (C++)
- Pointers (C++)
- Help me understand Pointers (C++)
- Sorting arrays of pointers with function? (C)
- Pointers (Part II) (C)
Other Threads in the C++ Forum
- Previous Thread: Is my code any good?
- Next Thread: [Question] exe to source file
| Thread Tools | Search this Thread |
Tag cloud for C++
api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library lines linker list loop looping loops map math matrix memory microsoft newbie news number output pointer problem program programming project python random read recursion recursive reference return rpg search simple spoonfeeding string strings struct temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






