Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I struggle with learning. I have to practice, and keep practicing, in order for something to stick. I don't do much C++ (once every month maybe) so I am constantly going over the same stuff.

I need some tasks to do so I can really understand pointers and their uses in the real world, rather than reading scenarios. I've created my own link list, but I want more advanced stuff like using pointer arithmetic and pointers and functions.

If anyone could provide some real world tasks to deepen my knowledge and experience with pointers I would be thankful.

I'm ok with data types because of my Java experience.

Look forward to some challenges (not too hard mind).

share

migration rejected from stackoverflow.com Jul 19 '13 at 0:34

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by MichaelT, Dan Pichelman, GlenH7, psr, gnat Jul 19 '13 at 0:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – MichaelT, Dan Pichelman, GlenH7
If this question can be reworded to fit the rules in the help center, please edit the question.

comments disabled on deleted / locked posts

6 Answers

Some possible project ideas:

  • Write a malloc implementation. Replace the system malloc with it in a non-trivial program and benchmark. Now make it faster.
  • Implement a generic red-black tree. Allow the user to pass in function pointers for key/value destruction and comparison
  • Implement a B+-tree using memory mapping. Now add write-ahead logging.
  • Write a simple language interpreter with garbage collection.
share
add comment
  • Implement your own red-black tree, with search, insertion, and deletion.
  • Implement your own linked lists, with iteration, insertion, and deletion.
  • Implement your own string manipulation algorithms, including substring searching.
  • Implement your own minimal Scheme implementation. ;-)
share
add comment

Implement your own collection types (lined list, map, whatever), and then implement a generic version of them using void*. That's what I did anyway and it taught me a lot.

share
add comment

Ok: write a memory pool library.

You'll have to work with:

  • pointers, lot of pointers ("pointers, pointers everywhere!"- not Herb Sutter ;) )
  • memory allocation/allocators
  • raw memory manipulation
  • templates (you will need this)
  • object memory tracking
  • etc.

Also, provide different pooling strategies/policies and associated standard allocators.

I think you'll touch both low and high levels of abstractions using pointers in implementing this. Disclaimer : it's not an easy task. If you can do better than boost::pool (that's possible and really wanted) you would contribute to a better world.

share
add comment

Do the Great Tree-List Recursion Problem. Without looking at the solution first. Then look at the solution. Determine where your answer varies from the solution, and why. Maybe try it without the STL first time around, then with the STL.

share
add comment

For a small but thoroughly demented challenge, figure out what this prints without compiling/running it first:

// Credit (or blame) for this code goes to Thad Smith of Boulder County CO.
#include<stdio.h>

char *c[] = { "ENTER", "NEW", "POINT", "FIRST" };
char **cp[] = { c+3, c+2, c+1, c };
char ***cpp = cp;

main()
{
    printf("%s", **++cpp);
    printf("%s ", *--*++cpp+3);
    printf("%s", *cpp[-2]+3);
    printf("%s\n", cpp[-1][-1]+1);
    return 0;
}

Don't let this scare you too much though -- although you obviously can abuse pointers this way, no sane person would ever write real code like this.

And to anybody who actually has written real code like this, well, shame on you (and your manager for letting it happen)!

share
    
This isn't really pointer abuse though -- it's more order of operations abuse. –  Billy ONeal Jun 16 '11 at 23:42
    
@Billy: Some of both, I think. –  Jerry Coffin Jun 16 '11 at 23:54
add comment