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
I wrote this "if" statement in a function with local double-type variables n4_1, n4_2 and n4_3:
if (n4_1 == 17 && n4_2 == 12 && n4_3 = 2003) { }
But Windows Studio Intellisense underlines the variables and says:
Expression must be a modifiable Ivalue
'=' : left operand must be l-value
The values of these variables are assigned through cin >> command.
I wanted to run the code inside the "if" statement ONLY if all three condition are true.
Please can you help me and explain me why is this incorrect and how can I correct it?
I'm a beginner so constructive criticism is welcome. Thanks in advance and please use simple words lol, I need to understand as clear as possible for the future.
Note that the final part of your if is an assignment. Note the single = in n4_3 = 2003.
You can only assign to n4_3 if it's a modifiable l-value: that is it can appear on the left hand side of =.
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 4 days ago.
Improve this question
I am currently writing my code to develop a grid over an airfoil in 2-D. Within one of my nested DO loops, i keep getting the "unclassified statement at (1)", no matter the bounds for the ELSE statement. Please see below for a copy of the nested loop.
!This will determine x-spacing over top of the airfoil`
DO j=1,nodes
DO i=rem+1,nodes-rem
IF (i<(nodes-rem)-((JLair-1)/2)) THEN
x(i,j)=c*(EXP(Kappaairfoil*((i-(rem+1))/(JLair-1.0)))-1.0)/(EXP(Kappaairfoil)-1.0)
ELSE IF (i==(nodes-1)/2+1) THEN
x(i,j)=c/2.0
ELSE
x(i,j)=c*(EXP(Kappaairfoil*((nodes-(rem+1)-i))/(kJLair-1.0)))-1.0)/(EXP(Kappaairfoil)-1.0)
END IF
END DO
END DO
However, when I run the code, I receive the following error:
gridspacing_2.f95:84:7:
84 | x(i,j)=c*(EXP(Kappaairfoil*((nodes-(rem+1)-i))/(kJLair-1.0)))-1.0)/(EXP(Kappaairfoil)-1.0)
| 1
Error: Unclassifiable statement at (1)
I have been able to get the code to not throw the error if I simply set x(i,j) equal to c, or very simple functions, but when I try to apply the full Rakich stretching function, I immediately receive the unclassified statement error. I appreciate you taking the time to read my problem, Any help is greatly appreciated.
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 11 months ago.
This post was edited and submitted for review 11 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I’m trying to make a tic-tac-toe program; I'm adding an if statement to change a variable's value if the condition is met. But when the condition is met, the variable that's value should be changed is 0.
I'm doing this in c++
cout <<player1 << ", which position would you like to add your X?: " << endl;
cin >> x1;
if (x1 == (b)) {
xx1=5;
}
N.B. When it asks you which position would you like it add your X, I am typing "a".
I expected xx1's value to change to 5 but instead of 5 it was 0.
Edit: I was using the "=" operator instead of the "==" operator. I ran the code and it worked, though now, a couple minutes later, it isn't working. I don't know what I did to make this happen, because the only thing that I did was setting it up for other letters.
To check if variables are equal you should use == operator.
You can read more about comparison operators here
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 5 years ago.
Improve this question
In my TimeCode.h I have following :
inline TimeCode::operator int() const;
Which should be able to execute whenever I cast TimeCode object to int.
But when I do something like :
(int) firstTimeCode > (int) scndTimeCode
The compiler throws the following error at me :
cast from 'TimeCode*' to 'int' loses precision [-fpermissive]
Does anyone know what is the problem and how it can be fixed ? Thank you very much in advance !
Look at the error message - it's telling you that you're converting TimeCode* to int - that is, at least one of your operands is a pointer to a TimeCode, not an actual TimeCode. So you need to dereference that pointer first to invoke your operator correctly.
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.
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 8 years ago.
Improve this question
I dont have much experience in cpp, let alone systemc.
Why doenst this work?
sc_in<sc_uint<8>> a,b;
adder.cpp:5: error: ‘a’ was not declared in this scope
adder.cpp:5: error: ‘b’ was not declared in this scope
adder.cpp:5: error: wrong number of template arguments (2, should be 1)
This does work:
sc_in<int> a,b;
In C++03, you can't have the two > characters next to each other because the compiler thinks you're trying to perform a right shift.
It then gets really confused, thinking you mean this:
sc_in<sc_uint<(8 >> a), b;
// ^ ^ ^
// ? | ? Compiler: "what are `a` and `b`?!"
// ! Compiler: "why two arguments?!"
If you had managed to get that far, it would later complain about the two missing > characters before ;, ironically taking you back to where you started.
You have to write sc_in<sc_uint<8> > instead.
That's fixed as of C++11.