C++ arrays and characters

This is a discussion on C++ arrays and characters within the C++ Programming forums, part of the General Programming Boards category; C++ arrays and characters is starting to get more difficult as I read on a book, which teaches C++ programming. ...

  1. #1
    Registered User
    Join Date
    May 2007
    Location
    Somewhere in Malaysia
    Posts
    16

    C++ arrays and characters

    C++ arrays and characters is starting to get more difficult as I read on a book, which teaches C++ programming. Can anyone give me some advice on how to learn it?
    Click on ads and get paid! + advice on getting free referrals
    Great and reliable Paid to click websites || View Ads and get paid || Get advice on how to get free referrals.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,411
    It's a tough subject for anyone just now starting to learn the language. Keep reading slowly, always doing more exercises than what the book suggests, and exploring new things without fearing compiler errors. What's the book?
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    How early are you in your learning? Have you learned about C++ strings yet?

    I would actually suggest you hold off on learning character arrays until you've spent time learning about arrays in general, which should be after you have done a lot of beginning C++ work. It should certainly be after you have learned how to use the C++ string class.

    If you want to follow your book and your book teaches character arrays (also known as C-style strings), then my only advice would be to go over that section of your book a few times and read tutorials on the internet about it. If you get stuck on specific problems we can probably explain them here.

  4. #4
    Registered User
    Join Date
    May 2007
    Location
    Somewhere in Malaysia
    Posts
    16
    Quote Originally Posted by Daved View Post
    How early are you in your learning? Have you learned about C++ strings yet?

    I would actually suggest you hold off on learning character arrays until you've spent time learning about arrays in general, which should be after you have done a lot of beginning C++ work. It should certainly be after you have learned how to use the C++ string class.

    If you want to follow your book and your book teaches character arrays (also known as C-style strings), then my only advice would be to go over that section of your book a few times and read tutorials on the internet about it. If you get stuck on specific problems we can probably explain them here.
    I've learnt about the string class. I think you mean the #string...right? Ok, anyways, I'm reading a book...published by...Orsborn. The author of the book is by John Smiley. The title is Learn to program with C++. The book is kind of...outdated...but not exactly outdated. Its meant for windows 2000 actually..or maybe even 98..lol
    Click on ads and get paid! + advice on getting free referrals
    Great and reliable Paid to click websites || View Ads and get paid || Get advice on how to get free referrals.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    >> I think you mean the #string
    I've never heard of #string, but we still might be talking about the same thing:
    Code:
    #include <iostream>
    #include <string>
    
    int main()
    {
        std::string first_name;
        std::cout << "What's your first name? ";
        std::cin >> first_name;
        std::cout << "Hello, " << first_name;
    }
    If you know that kind of string, great. Do you know arrays in general? A C style string is implemented with an array of characters that has the special property having one extra element to mark the end of the array (C style arrays don't keep track of their own size). So if you know arrays in general that's a good step.

    Do you have any specific questions that prompted this thread?

  6. #6
    coder
    Join Date
    Feb 2008
    Posts
    127
    I hope this will help you as it helped me:
    http://www.cplusplus.com/doc/tutorial/ntcs.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D arrays and storing characters
    By John_L in forum C Programming
    Replies: 4
    Last Post: 10-13-2007, 12:17 PM
  2. Strings and Characters in arrays.
    By akidamo in forum C Programming
    Replies: 24
    Last Post: 04-06-2006, 10:11 PM
  3. Deleting characters from 2d arrays
    By `firefox in forum C Programming
    Replies: 4
    Last Post: 05-21-2005, 05:18 PM
  4. strings or arrays of characters?
    By Callith in forum C++ Programming
    Replies: 13
    Last Post: 12-26-2004, 10:28 AM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 08:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21