Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
When I try to compilate my code a
"unit1.pas(53,1) Error: Illegal expression"
in else line appears.
procedure TForm1.Button1Click(Sender: TObject);
var x: real;
begin
x:=StrToFloat(Edit1.Text);
if x>=0
then
Label1.Caption= FloatToStr(x)
else
Label1.Caption:= Floattostr(x);
What's wrong is the expression before the else. You have an equals sign = where you ought to have an assignment operator :=, as you have in the else:
if x>=0 then
Label1.Caption := FloatToStr(x)
else
Label1.Caption:= Floattostr(x);
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 days ago.
Improve this question
How to change comma to period when typing double number in TextField?
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 months ago.
Improve this question
auto data = new char[480][640][3]();
char data = new char[480][640][3]();
First works.
Second doesnt.
Why? Isn't auto supposed to just replace itself with the type of the initializer?
Because the type isn't char. The type is char(*)[640][3] and the declaration would be written as
char (*data)[640][3] = new char[480][640][3]();
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Why does below command highlight e as well with digits?
grep '[[:xdigit:]]' search.txt
This is intended, as it searches for hexadecimal digits.
The man-page states:
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I wanted to clear string from unwanted chars, and I tried to iterate it through a loop like this.
for(auto it=numer.begin(); it!=numer.end(); ++it)
{
if(*it=='-') numer.erase(it);
}
The error is: "expected primary-expression before '=' token";
I could, of course, I could do this with [] operator. But I am wondering why it doesn't work.
I appreciate your help.
If you want to remove all instances of a character from a string, a simple way to do that would be to use the standard erase-remove(if) idiom:
numer.erase(std::remove(numer.begin(), numer.end(), '-'), numer.end());
See also:
https://en.cppreference.com/w/cpp/string/basic_string/erase
https://en.cppreference.com/w/cpp/algorithm/remove
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
given a string in this format:
07:05:45PM
I am to convert it to military time.
My idea is to check element 8 of the string for whether it is a 'P' or an 'A' and modify the string accordingly however this expression:
if (time[8] == 'P' );
always evaluates as true whether time[8] is an 'A' or a 'P' or even a '7'
why?
Because you have an extra semicolon, right after the if statement.