format value type float in (Programming Language C/C++) [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How show 00156,00
float number = 156;
printf("%5.2f",number);
The output of the example above:
Output: 156.00

You need to pass the 0 flag for leading zeros, and the field width must be wide enough to have any leading characters printed. So you might try this:
printf("%08.2f", number);
The . verses , (aka, the "radix character") is determined from the LC_NUMERIC portion of the locale. See man setlocale for information on setting this programatically.

Related

Taking input using delimiter in C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
After taking those values I have to store the values in two different arrays (say x and y)
So the only error I can immediately see is this
float* a = NULL;
a = new(nothrow)float;
which should be
float* a = new float[count];
Your version only allocates enough space for a single float when you really need space for count floats.
When you have code that isn't working, and you want to ask a question about it you really should say exactly what happens when you run the code. Doing this will help get you better answers.

How to give regular expression for name with space & min max length? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Assume only characters are in English and space is allowed
[a-zA-Z]+(\s|_)?[a-zA-Z]*
Playground:- https://regex101.com/r/1vM2H3/1
"Satish Patro" (accepted)
"Satish " (accepted, but shouldn't be accepted)
But, two things are not handled
if underscore is there, it should have letters at the end
So, "satish " not allowed
How to handle regex for matching length for min = 1, max = 20
How to handle those things
Why dont you try this?
((?=.*_)^[a-zA-Z_\s]{1,19}[a-zA-Z]$)|((?!.*_)^[a-zA-Z\s]{1,20}$)
No Space and UnderScore as first character
((?=.*_)^[a-zA-Z][a-zA-Z\s_]{1,18}[a-zA-Z]$)|((?!.*_)^[a-zA-Z][a-zA-Z\s]{1,19}$)
you need to specify that you want to match the whole string
^[a-zA-Z]+\s?[a-zA-Z]*$

I need a regex for the following combination [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
mission_id: a498094578a
mission_id: a493453456
mission_id: 498343454a
mission_id: 34534535345
From the above 4 mission_id's I need your help in writing a regex pattern which covers all the four mission_id but need to select only the numbers.
So one the first one - need to exempt 'a' and only the numbers.
mission_id:\s*\w?(\d*)\w?
That should work; maybe add any flags you need for parsing multiline text or whatever.
www.regexr.com is a great resource for trying out RegExps

Regex pattern to not equal 0 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I want to pass values those are not equal zero (0). What is the best performing regex pattern for this ?
[^0]+
Means: Any character besides zero must occur at least once

regex: check if values exist in between commas [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In Perl, I would like to determine if a given string is valid, the rule is to check if values exist between commas.
e.g. abc,abc is a valid case, but abc, or abc,,abc are not.
m/^\s*,|,\s*,|,\s*$/
matches all invalid combinations, assuming whitespace does not count as "values".