This question already has answers here:
Inserting an integer value in a TextBox
(5 answers)
Closed 7 years ago.
I have one Text Box in windows application. This Text box can only hold a String value and not an integer. How can i pass the integer as a String to the text box?
int a=3;
//textBox1->Text = ???
Assuming you are working with VisualC++, you can convert integer to string as follows:
yourIntegerValue.toString();
in your case:
textBox1->Text = a.toString();
Please consider using the search function, next time you are tempted to ask. This question is a duplicate for:
Inserting an integer value in a TextBox
Related
This question already has answers here:
How to put a static text (postfix, prefix) in QLineEdit?
(2 answers)
Closed 2 years ago.
It's possible to set a fix string at first of QLineEdit? something like this:
Which in here $ is constant and user could not remove or edit it.
use the input mask in the object: e.g.
ui->lineEdit->setInputMask("$ 000.000.000.000 ");
will look like
This question already has an answer here:
Increasing the print depth in SML/NJ
(1 answer)
Closed 6 years ago.
I'm using Emacs to write a simple function in sml of about 4 lines and when I try to call the function/evaluate it in the buffer it returns this with 3 dots at the end
val it = [1,2,2,2,2,2,2,2,2,2,2,2,...] : int list
What's the dots at the end? My code doesn't print any dots. Is this is from Emacs or sml? any hints please.
Also I'm supposed to get a longer list like
[1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
is that why the dots there?
is that why the dots there?
Yes.
This question already has answers here:
Finding Max with Lambda Expression in Java
(3 answers)
Closed 6 years ago.
I have an empty list of integers:
final List<Integer> reservedMarkers = new ArrayList<>();
and I will fill this list with the marker property of a list of objects, such like this:
scheduleIntervalContainers.stream().forEach(s -> s.getMarker(), reservedMarkers.add(s));
My final target would be to get the highest marker number but actually I dont know a better way as getting all marker numbers, than sort it and than get the highest one.
this does not work for sure, is there a possibility to do this in this way?
Use IntStream to find max value:
OptionalInt max = scheduleIntervalContainers.stream()
.mapToInt(s -> s.getMarker())
.max();
This question already has answers here:
Skipping expected characters like scanf() with cin
(5 answers)
Closed 7 years ago.
Lets say i am given input
{ [1, 1], [2,10] , [-10, 20] }
I have to retrive number and check if the input is correct ( if "," isnt missing or if { and } are at the start/end )
In c, i could just use
scanf(" %c%d, %d%c",&zatvorka,&jedna,&dva,&zatvorka_dva);
In a while loop to scan the input , but how could i do it in c++? As far as i know , to cin is used to retrive data but it has no pattern like scanf() which would make it hard to retrieve data in such pattern and check if it is correct. How could i scan input like that ( for example) in c++?
The scanf function is available in C++ as well. You need to include the cstdio header file to access it.
More info:
http://www.cplusplus.com/reference/cstdio/scanf/
http://en.cppreference.com/w/cpp/io/c/fscanf
This question already has answers here:
What is the easiest way to parse an INI File in C++? [closed]
(13 answers)
Closed 8 years ago.
I am a c++ beginner and I have a (probably simple) question. So far i have defined several variables:
double Start = 0;
double End = 1;
int Steps = 100;
I want to change these values to a value that I have stated in a text file "paramaters.txt":
x_start = 0
x_end = 10
num_steps = 100
So my c++ needs to read the file and change the double End from 1 to 10. Reading the file can be done with this function:
std::ifstream file("parameters.txt")
I want to define a variable of type std::string, called label. Then i want to read the ’label’ from the file. Using a group of ’if (label == ”value”)’ statements to determine if I'm dealing with the start, end of the number of steps. Within the if-statement, the value of 10 would stand for the end for example.
I hope that someone can help me.
Regards,
It seems you want to read a file for some values. You can do that by reading file line by line and then parsing each line.
For e.g in your case you would separate the line into two words with demiliter as "=".
But often the best way to read file for some values is to use some libraries. Like you can use boost::program options.