Results 1 to 13 of 13
  1. #1
    Beginner C++ question

    Member Since
    Oct 16, 2009
    Posts
    18
    Beginner C++ question
    Hello, I am learning C++ and am using Xcode as my IDE. This may sound like a dumb question but are there different types of C++? I have been trying to compile some basic source code from planet-source-code.com (calculators and things like that). Some of them work without a problem but the majority have several errors and will not build. I'm not sure if this makes a difference but under compatibility they all say general C++ (which I assumed is what I would want). Could someone please explain to me why this is happening?

  2. #2
    Beginner C++ question
    cuhnool's Avatar
    Member Since
    Jun 02, 2008
    Location
    Louisville
    Posts
    1,502
    Specs:
    MacBook 2.1GHz Core 2 Duo | 1GB RAM | OS X 10.6.3 | 250GB External HD | 8GB iPod Touch 1st Gen 3.1.3
    Can you provide links to the programs?

  3. #3
    Beginner C++ question

    Member Since
    Oct 16, 2009
    Posts
    18
    here is one of the codes I could not get to compile.

  4. #4
    Beginner C++ question
    cuhnool's Avatar
    Member Since
    Jun 02, 2008
    Location
    Louisville
    Posts
    1,502
    Specs:
    MacBook 2.1GHz Core 2 Duo | 1GB RAM | OS X 10.6.3 | 250GB External HD | 8GB iPod Touch 1st Gen 3.1.3
    Quote Originally Posted by O'Brien View Post
    here is one of the codes I could not get to compile.
    Also, have you learned the "Hello, World!" program? You should start from the very beginning, such as learning what libraries are, syntax, header files, variables, stuff like that. Learning the absolute basics will help give you a grasp of what to look for in a program when it relates to finding errors.

    I would suggest picking up a book for learning C++, or going here. I myself will occasionally glance through Sams Teach Yourself C++ book. Aside from that, the main book I use to learn C++ is from Lawrenceville Press, and it's called "A Guide to Programming in C++". It's ISBN is 1-879233-90-8 if you want to pick it up.

  5. #5
    Beginner C++ question

    Member Since
    Oct 16, 2009
    Posts
    18
    Yes I have learned the "Hello World!" as well as variables, functions, arrays etc. (I am currently working my way through a tutorial) I've just been trying to teach myself some practical programming by analyzing other peoples programs. Thanks for the suggestions. I'll definitely look into those books.

  6. #6
    Beginner C++ question
    cuhnool's Avatar
    Member Since
    Jun 02, 2008
    Location
    Louisville
    Posts
    1,502
    Specs:
    MacBook 2.1GHz Core 2 Duo | 1GB RAM | OS X 10.6.3 | 250GB External HD | 8GB iPod Touch 1st Gen 3.1.3
    Quote Originally Posted by O'Brien View Post
    Yes I have learned the "Hello World!" as well as variables, functions, arrays etc. (I am currently working my way through a tutorial) I've just been trying to teach myself some practical programming by analyzing other peoples programs. Thanks for the suggestions. I'll definitely look into those books.
    Alright, just checking if you did, lol. It would be quite the challenge jumping right in without necessary knowledge. But you got that covered so we're good there

    I am looking at the source code now.

    **EDIT**

    Looked at the errors. You do not have the conio.h directory. conio.h is a MS-DOS header file, so it's not included with OS X.

    more information

  7. #7
    Beginner C++ question

    Member Since
    Oct 16, 2009
    Posts
    18
    Ah thank you that makes sense. So I'm assuming I was wrong in thinking that (general) C++ means that it would be universal. Or did that person just put the wrong category?

    Oh I see your link now about making conio.h readable in osx. I'm still a bit confused about what the syntax would be though. Would it be #include <conio.h> /usr/lib/libncurses.dylib ?

  8. #8
    Beginner C++ question
    cuhnool's Avatar
    Member Since
    Jun 02, 2008
    Location
    Louisville
    Posts
    1,502
    Specs:
    MacBook 2.1GHz Core 2 Duo | 1GB RAM | OS X 10.6.3 | 250GB External HD | 8GB iPod Touch 1st Gen 3.1.3
    Quote Originally Posted by O'Brien View Post
    Ah thank you that makes sense. So I'm assuming I was wrong in thinking that (general) C++ means that it would be universal. Or did that person just put the wrong category?
    The only header file I know of that doesn't work with Unix-based systems is conio.h

    If there are others, I'm sure there are workarounds or other header files that have identical functions. There shouldn't be too much of a difference.

  9. #9
    Beginner C++ question

    Member Since
    Oct 16, 2009
    Posts
    18
    Alright I'll give it a try. Thanks!

  10. #10
    Beginner C++ question
    cuhnool's Avatar
    Member Since
    Jun 02, 2008
    Location
    Louisville
    Posts
    1,502
    Specs:
    MacBook 2.1GHz Core 2 Duo | 1GB RAM | OS X 10.6.3 | 250GB External HD | 8GB iPod Touch 1st Gen 3.1.3
    Quote Originally Posted by O'Brien View Post

    Oh I see your link now about making conio.h readable in osx. I'm still a bit confused about what the syntax would be though. Would it be #include <conio.h> /usr/lib/libncurses.dylib ?
    I just saw this, lol

    Nope. I corrected the program, and I have it working. I'll show you in a bit, let me grab some snapshots.

  11. #11
    Beginner C++ question
    cuhnool's Avatar
    Member Since
    Jun 02, 2008
    Location
    Louisville
    Posts
    1,502
    Specs:
    MacBook 2.1GHz Core 2 Duo | 1GB RAM | OS X 10.6.3 | 250GB External HD | 8GB iPod Touch 1st Gen 3.1.3
    Go to Project >> Add to Project...


    Press Command+Shift+G to bring up the "Go to the folder..." pane. Type in /usr/lib. Click Go


    Scroll down until you find the libcurses.dylib file. Click Add


    Click Add again


    Replace the highlighted line with curses.h


    Delete the highlighted line


    Delete the highlighted line


    Click Build and Go

    Click the Console button (the arrow is pointing to it)


    Go to the Console, and type in an equation using the five operators. The equation I used was 5 ^ 5 which came out to 3,125. I then typed in n to end the program.


    --

    Hope this helps you out! Should work for you now

  12. #12
    Beginner C++ question

    Member Since
    Oct 16, 2009
    Posts
    18
    borden of
    Ah thank you so much. I was still getting the error: 'clrscr' was not declared in this scope. I tried removing this function (?) from the code as it did not seem to have a purpose. When I did that it ran fine but when prompted if I wanted to solve another problem I typed "y" and the program exited as if I had typed "n".

    edit* Oh now I see the part of your post about deleting the textgreen and clrscr.

    edit** Never mind I fixed it. Thanks again for all your help!

  13. #13
    Beginner C++ question
    cuhnool's Avatar
    Member Since
    Jun 02, 2008
    Location
    Louisville
    Posts
    1,502
    Specs:
    MacBook 2.1GHz Core 2 Duo | 1GB RAM | OS X 10.6.3 | 250GB External HD | 8GB iPod Touch 1st Gen 3.1.3
    Quote Originally Posted by O'Brien View Post
    Ah thank you so much. I was still getting the error: 'clrscr' was not declared in this scope. I tried removing this function (?) from the code as it did not seem to have a purpose. When I did that it ran fine but when prompted if I wanted to solve another problem I typed "y" and the program exited as if I had typed "n".

    edit* Oh now I see the part of your post about deleting the textgreen and clrscr.

    edit** Never mind I fixed it. Thanks again for all your help!
    You're welcome! Glad to help out. Good luck with your further studies in C++ !

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Beginner question
    By whatthewhat in forum Switcher Hangout
    Replies: 7
    Last Post: 12-01-2011, 04:20 PM
  2. C++ Beginner simple fstream question
    By Kenya253 in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 10-04-2009, 05:35 PM
  3. Beginner question
    By saoslund in forum OS X - Operating System
    Replies: 2
    Last Post: 02-13-2009, 01:22 AM
  4. Dumb iTunes beginner question
    By 00bolt in forum Music, Audio, and Podcasting
    Replies: 3
    Last Post: 12-21-2008, 11:34 PM
  5. mac beginner question
    By chihiro in forum OS X - Apps and Games
    Replies: 5
    Last Post: 10-18-2007, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •