Integer creation program

This is a discussion on Integer creation program within the C Programming forums, part of the General Programming Boards category; A program that makes an integer with the name you specify. Eg. I run the program, and put "Hello" as ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    26

    Integer creation program

    A program that makes an integer with the name you specify.

    Eg. I run the program, and put "Hello" as the integer name, and it creates an integer called Hello.

    Is this possible to do?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    variable names have no meaning after the program is compiled, so, no.

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    26
    Ok, thanks for the quick response.

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    You dont' necessarily have to use a named variable, you could have a linked list or some sort of table full of name's and their values, ie:
    Code:
    struct cell_t {
        char name[16];
        int value;
    } cell;
    And a linked list of 'cells', for example cell 1 would contain, name = "Hello" value = 2 or whatever.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    It's dead easy to do in C++, with say

    std::map< std::string, int >
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-20-2009, 11:37 PM
  3. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  4. No Match For Operator+ ???????
    By Paul22000 in forum C++ Programming
    Replies: 24
    Last Post: 05-14-2008, 10:53 AM
  5. Linked Lists Integer addition ? HELP Please??
    By green_eel in forum C Programming
    Replies: 3
    Last Post: 03-12-2003, 03:36 PM

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