Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to create array using linked list....

 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to know how do i create linked list using array, and how can i create array using linked list???
with example...
 
Anthony Aj Williams
author
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit Jain wrote:i want to know how do i create linked list using array, and how can i create array using linked list???
with example...


Creating a linked list from an array is straightforward:



Creating an array from a linked list is less so --- you need to dynamically allocate your array and copy in the data:



Using dynamic arrays is generally a bad idea though. It's better just to use std::vector instead, which manages the memory for you automatically.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you suggest me any good book for c and c++??
 
Anthony Aj Williams
author
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit Jain wrote:can you suggest me any good book for c and c++??


For C++ I would recommend "Accelerated C++" by Koenig and Moo. I can't think of a good introductory book for C, and I'm inclined to say that it's not worth learning C separately until you really need to, as good C idioms are quite different from good C++ idioms, and learning both will lead to confusion, and make your C++ worse.
 
Stephan van Hulst
Bartender
Pie
Posts: 5893
63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree, don't mess around with C unless you have to. It's an old low level language that may stand in the way of your learning process at this time.

If you do decide to learn it, the absolute best thing you can read is Kernighan and Ritchie's "The C Programming Language". I believe you can download it as a PDF.
 
Doug Slattery
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree, don't mess around with C unless you have to. It's an old low level language that may stand in the way of your learning process at this time.


If you are trying to learn OO programming, then C is not a good choice. Go with C++.

I don't agree that C is a low level language though, but that's just me ;). I started with C in the late '80s & used it solidly for almost 20 years. Now I am pretty much just doing Java. C gives you the freedom to do pretty much what you want programmatically. You are not bound by contracts or "save me from myself" issues the compiler tries to enforce as with Java.

I still prefer C and have a coding style that mimics OO which has evolved over the years.

As for books, I can't recommend a modern publication for C, but for C++ the book by the man himself - Stroustrup, The C++ Programming Language 3rd edition (don't know if a later version has been published) is pretty good.

Hope that helps.
- Doug

-- Nothing is impossible if ImPossible
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic