From hardcoded to user input value

Hi,

I have been struggling for a long time to find out how to change a hardcoded variable value to a user defined value, but not have any luck yet.

I have created a C++ win32 window app in MS Visual Studio. My problem is that I am using some open source code in my app that have a hardcoded variable that I need to make user selectable. That is, I want it to be user defined instead of beeing hardcoded as it is now.

The user input should only be a write a ip address of choice, like i.e 192.168.0.22

How do I manage to have the user input to my program?

The program

The user should be able to write in an ip address in any way, into a inputbox if possible, reading a txt file only the ip adresss as data, XML or whatever is fine.
add a text box

and update text on change

and set the hardcoded variable to = the updated text of the text box
1
2
3
std::cin >>
getline(std::cin, variablehere)
std::cin.get(variable) 

these are a list of some of the user input functions.
for example
if i want to ask the the user for his/her name.
i would do
1
2
std::cout << "Enter your name please: ";
std::cin >> name;//gets the name 

if the user inputs bill bill and do std::cout << name;you will get
bill
this is because std::cin ignores white space.
if you want to include white space use getline. for example
1
2
3
std::cout << "Enter your name please: ";
getline(std::cin, name);
std::cout << name;

the output is
bill bill
this is because getline includes white space and stops inputing when the user enters a new line character(hits enter).

i hope this makes things clear for you.
Hi,
thanks for your replies.


oonej, I will try to see if you suggestion works.


ui uiho, my win app is not a concole program, but I Win32 window program.

how can I use your suggestion in GUI environment?


rgs,


Topic archived. No new replies allowed.