Hamid
You must put it inside { }
Anonymous
Really?
Anonymous
That's how it is?
Anonymous
No it's not. I've seen it being used for char
Anonymous
Like for operations
Hamid
'area' is not acceptable as a char
Anonymous
'area' is not acceptable as a char
What identifier should I use then?
Hamid
Does this code even compile? 😐
Anonymous
Does this code even compile? 😐
I swear it does and it always uses default
Hamid
I swear it does and it always uses default
Use if else instead Switch case is only for int/char type
Anonymous
I'll try
Anonymous
Thanks
Anonymous
Anonymous
you defined normal as a char and then use it as a string
Ooh so I should have used a char array?
Andrew
Ooh. So I should use string then
it should be better like press 1 to get circumference , press 2 to get area. instead of letting the user write
Andrew
Ooh so I should have used a char array?
yes, or include <string> and then use string
Andrew
Press 1? Press 2? How is that?
instead of this Enter desired objective. choose from either circumference or area\n this press (1) to get circumference , (2) area
Anonymous
Oh so I should replace the case 'circumference' and case 'area' with press 1 or 2
Andrew
yh
Anonymous
I mean with 1 or 2 like case 1 case 2
Anonymous
yh
Excuse me?
Anonymous
yes
Ooh. Okay thank you very much.
Anonymous
So if my switch is more than one line what should I do?
Anonymous
If code inside a case was more than one line
I think it's something like case 1: {cout <<circumference*M_PI*2 <<endl; } break;
Anonymous
Right?
Andrew
I think it's something like case 1: {cout <<circumference*M_PI*2 <<endl; } break;
you dont need curly brackets case 1: cout <<"line1"<<endl; cout <<"line2"<<endl; break; case 2: //code break;
Anonymous
Okay
Anonymous
plz
Anonymous
can i any one help me
Anonymous
Write a program to print menu as in (a) from printMenu() function. Then write a function, called simpleCalculator(). In the function, request the user to input two real numbers and one of the letter codes A, S, M, D or L. Based on the code entered by the user, the program needs to perform an appropriate arithmetic operation to the two numbers. Then, display the result of the operation. The letter codes and their operations are as listed below:------------------------------------------------ Simple Calculator Program --------------------------------------------------- A - Addition S - Subtraction M - Multiplication D - Division ---------------------------------------------------
Anonymous
??????????
Anonymous
the program needs to perform an appropriate arithmetic operation to the two numbers. Then, display the result of the operation
Vlad
Go do it
Anonymous
????
Andrew
you know how to make a function to sum 2 numbers?
Vlad
????
It would take you like an hour if you've never programmed before
Vlad
Maybe less. Depends how much are you gonna fight with syntax lmao
Anonymous
i know i want some help only
Vlad
i know i want some help only
We won't do it for you. It is C++ chat. Why would we advise you to not learn C++ and just get a solution?
Vlad
/report
Andrew
im curios is there a way to print all variables name in the scope like int main(){ int var1; int var2; int var3; printScopeVariables(); //outputs ->(var1, var2, var3) }
Andrew
like there should be a place in memory where the variable names are saved, or they are discarded at compile time?
Pavel
like there should be a place in memory where the variable names are saved, or they are discarded at compile time?
They are discarded, but if you build with debug information they are saved there, and you can access it through debugger commands
Pavel
More so, if you compile with optimizations enabled, the values of the variables can no longer exist in memory (they can become a part of assembly commands if they were constants, be stored directly in registers if their necessary lifetime is short, or be optimized in some way)
Andrew
thanks
Andrew
make sense
Sunil
#include<stdio.h> int main() { printf("%x", -1<<1); getchar(); return 0; }
Sunil
Guys can u explain
Ehsan
shift -1 in binary representation to the left
Pavel
#include<stdio.h> int main() { printf("%x", -1<<1); getchar(); return 0; }
%x outputs lowercase hexadecimal -1 is all ones in memory (if "two's compliment" is used, which is likely), A byte with all ones if "ff" in hexadecimal. << is a left bit shift, it moves all bits to the left, so the rightmost bit becomes zero
Sunil
# include <stdio.h> # define scanf "%s Geeks For Geeks " main() { printf(scanf, scanf); getchar(); return 0; }
Sunil
Output: %s Geeks For Geeks Geeks For Geeks
Sunil
How is this
Hamid
# include <stdio.h> # define scanf "%s Geeks For Geeks " main() { printf(scanf, scanf); getchar(); return 0; }
with #define <something> <value> you can define a macro it simply replace all <something>s in your code with <value>
Hamid
# include <stdio.h> # define scanf "%s Geeks For Geeks " main() { printf(scanf, scanf); getchar(); return 0; }
so your code turns into this: # include <stdio.h> main() { printf("%s Geeks For Geeks ", "%s Geeks For Geeks "); getchar(); return 0; }
Abhishek
Can anybody share some good resource for learning STL
Vitalii
Sorry, how to fix that warning?: int row = 5, cols = 3; double* matrixC = new double[cols]; for (int i = 0; i < cols; ++i) { matrixC[i] = 0; for (int j = 0; j < rows; ++j) { matrixC[i] += matrixA[j][i] * matrixB[j]; } } matrixY[0] = matrixC[0] / matrixL[0][0]; matrixY[1] = (matrixC[1] - matrixL[1][0] * matrixY[0]) / matrixL[1][1]; // warning here: Reading invalid data from "matrixC": readable size is "cols * 8" bytes, but only "16" bytes can be read matrixY[2] = (matrixC[2] - matrixL[2][1] * matrixY[1] - matrixL[2][0] * matrixY[0]) / matrixL[2][2];
Anonymous
if B::K is found in B, and i link A to B and C to A, and C uses B::K, then the linker SHOULD search A for B::K, be unable to find it, and then search A's dependancy of B, for B::K and find it, right? as i get unknown reference if i link A against B and C against A and i DONT get unknown reference if i link C against BOTH A and B EXPLICITLY like wtf ;-; eg target_link_libraries(A B) target_link_libraries(C A) /* fails with unknown reference B::K */ target_link_libraries(C A B) /* works */
Anonymous
imma just add this instead message(STATUS "in ${CMAKE_CURRENT_LIST_FILE}:") message(STATUS " please remember to add `import_library__AndroidDAW_Midi()`") message(STATUS " after `import_library__AndroidDAW_Plugin()`") message(STATUS " (or before if you are alphabetical ordering)") message(STATUS " and then link to `AndroidDAW_Midi`")
Liam
@MRT_1400 template <typename T> struct Singleton { static T* get() { static T ins; return &ins; } T* operator->() const { return get(); } }; using: Singleton<Payload>::get()->interface_of_payload(); or Singleton<Payload>()->interface_of_payload();
MRT
static T ins; ?
Nils
i need to create in heap
Make it a shared_ptr then