Thread: Age Generating Console Program

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    >>transform ( answ.begin(), answ.end(), answ.begin(), ptr_fun(::tolower) );
    The transform is wrong. You are invoking undefined behavior here.
    You really should be doing

    transform ( answ.begin(), answ.end(), back_inserter(answ), &tolower );

    back_inserter can be found in <iterator>.
    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.

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Elysia View Post
    >>transform ( answ.begin(), answ.end(), answ.begin(), ptr_fun(::tolower) );
    The transform is wrong. You are invoking undefined behavior here.
    You really should be doing

    transform ( answ.begin(), answ.end(), back_inserter(answ), &tolower );

    back_inserter can be found in <iterator>.
    Eh? A string iterator is an output iterator, so far as I can tell. Also I don't think he wants the lowercased version of his string stuck at the end of his regular string.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. Help with console program
    By feso4 in forum C++ Programming
    Replies: 3
    Last Post: 10-22-2006, 11:53 AM
  3. my first windows console program
    By Syneris in forum Windows Programming
    Replies: 3
    Last Post: 04-08-2002, 03:18 PM
  4. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 01:42 PM
  5. semaphores using C++ in console program
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 12-20-2001, 12:46 PM