Thread: Simple poker code

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Quote Originally Posted by got1sleeve View Post
    My teacher must have confused me then. I originally had the & in there and he said strings are pass by reference so i didn't need them in there and thats why they were causing the link error.
    There's a difference here between C-style strings and C++ std::strings. A C-style string is an array of characters, so it gets passed to a function as a pointer (which, in C, is as close as we get to pass-by-reference). A C++ string is a single type (not an array), so it needs to be passed by reference (using &) if we want changes to be seen in the main program.

  2. #17
    Registered User
    Join Date
    Jan 2008
    well I struggle with c++ let alone know anything about c haha i stick to this forum....but any suggestions as to why the code doesn't output anything?

  3. #18
    Join Date
    Oct 2007
    Inside my computer
    Let's fire up the debugger!

    Duh! Of course!
    	int ansr;
    	cout << "\n\nTo deal yourself a poker hand please press D. " ;
    	cin >> ansr;
    You're reading a string or a char into an int. Ansr must be a char.
    You can also remove n from the function because you aren't using it.

    Also, in get card:
    Apparently, you get an implicit conversion from int to char here, so you might as well do an explicit conversion by doing a cast and silencing a warning.
    Last edited by Elysia; 01-31-2008 at 04:55 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 14
    Last Post: 11-23-2005, 08:53 AM
  2. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Windows Programming
    Replies: 0
    Last Post: 10-14-2002, 01:29 PM
  3. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM
  4. Simple Code, looking for input.
    By Alien_Freak in forum C Programming
    Replies: 3
    Last Post: 03-03-2002, 11:34 AM