Thread: help with chars...

  1. #1
    Registered User
    Join Date
    Jul 2002

    Question help with chars...

    hi all,

    i was just wondering if it was posible to create a char with a name enter by the user e.g.

    if the user enters 'welcome' it will create a char called 'welcome' for example

    char name_entered_by_user[255]
    thx for any help just ask if ur not clear on what i mean
    Theres a sucker born every minute, but a swallower is harder to find

  2. #2
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Nope, not possible with C++ as you want it. However, you can kind of fake it with a map
    #include <iostream>
    #include <string>
    #include <map>
    using namespace std;
    int main()
        map<string, string> strings;
        // Assume the names are entered interactively ;)
        strings["beep"] = "Beep!";
        strings["boop"] = "Boop!";
        strings["snic"] = "Snickerdoodle!";
        map<string, string>::iterator i;
        for (i = strings.begin(); i != strings.end(); ++i)
            cout<< i->second <<endl;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. while condition question..
    By transgalactic2 in forum C Programming
    Replies: 3
    Last Post: 04-04-2009, 04:49 PM
  2. Counting how many chars in a string
    By tigs in forum C Programming
    Replies: 4
    Last Post: 08-05-2002, 12:25 AM
  3. really got stuck with unsigned chars
    By Abdi in forum C Programming
    Replies: 7
    Last Post: 06-11-2002, 12:47 PM
  4. move chars position
    By SpuRky in forum C Programming
    Replies: 3
    Last Post: 06-09-2002, 02:59 AM
  5. fancy strcpy
    By heat511 in forum C++ Programming
    Replies: 34
    Last Post: 05-01-2002, 04:29 PM