This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes C / C++ and the fly likes how to create array using linked list.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "how to create array using linked list...." Watch "how to create array using linked list...." New topic
Author

how to create array using linked list....

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
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

Joined: Jun 10, 2011
Posts: 56
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.


Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/
just::thread C++11 thread library http://www.stdthread.co.uk
Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
can you suggest me any good book for c and c++??
Anthony Aj Williams
author
Ranch Hand

Joined: Jun 10, 2011
Posts: 56
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

Joined: Sep 20, 2010
Posts: 3647
    
  17

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

Joined: Sep 15, 2007
Posts: 294
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to create array using linked list....