zwy
/get ide
Anonymous
So I found out that the syntax for sizeof is sizeof unary-expression sizeof ( type-name ) Why does type name require parentheses? I get that the C standard says so, but does it have a reason, or should I stop asking questions like these and accept the standard for what it is?
Anonymous
Basically saying, using parentheses when the argument is a expression (e.g 10 * int, 50 * double ), and feel free to choose when argument is a variable.
Anonymous
Because the Operator Procedence rule in c. sizeof is same priority as + unary operator, so without parentheses compiler will not think 10 * int as a single expression. see https://www.tutorialspoint.com/cprogramming/c_operators_precedence.htm
Anonymous
I'm not a native English speaks,ples forget my grammar mistaking.
Anonymous
Basically saying, using parentheses when the argument is a expression (e.g 10 * int, 50 * double ), and feel free to choose when argument is a variable.
"feel free to choose when argument is a type" You've got it a bit wrong I think. Parentheses is not optional when argument is a type. So we always have to use sizeof(int) even though sizeof int doesn't seem to be causing any problems.
Anonymous
Yes, i'm wrong. thks
Anonymous
np
Anonymous
So I found out that the syntax for sizeof is sizeof unary-expression sizeof ( type-name ) Why does type name require parentheses? I get that the C standard says so, but does it have a reason, or should I stop asking questions like these and accept the standard for what it is?
Because of ambiguous things like sizeof int * + 1 (which could be interpreted as sizeof(int) * (+1) or sizeof(int*) + 1 In C, a type specifier doesnt appear standalone in an expression as a result of which the grammar doesnt have to specify whether * is part of a type or if it is a part of an expression. So C requires a type to always be specified in parentheses with sizeof to avoid such ambiguous cases.
Vlad
wdym?
Vlad
What do you mean
Anonymous
Pre - Print Root first, Traverse(Left Child), Traverse(Right Child) In Order - Traverse(Left Child), Print Root, Traverse(Right Child) Post Order - Traverse(Left Child), Traverse(Right Child), Print Root Traverse in each case refers to Post Pre or Inorder traversal of each child node respectively
Vlad
Binary tree?
Vlad
Well it's just about where your action's gonna be
Vlad
And how your data is stored and sorted in the BST
Vlad
4 / \ 3 5
Vlad
in order: you go left first, output 3 then 4 and 5
Vlad
pre order: 4, 3, 5
Vlad
post order: 3, 5, 4
Anonymous
For this Pre will be a b c d In Order will be d c b a Post will be d c b a
Stark39377
Can anybody share me resources from where to learn c++ from scratch?
Владислав🇺🇦
Hi everyone. I am wondering when it is a right moment for a C++ developer to switch to LLVM environment. What knowledge should I have before doing it? I tried Clang for some time and I really liked it. Now I am thinking whether I should set up the whole LLVM environment and wouldn't it be a mistake. I use C++ for more than 4 years but I am only a 2nd year student and I have no serious projects in my portfolio (actually asking this question while starting one). Any advice is much appreciated
Владислав🇺🇦
Isn't clang a frontend to llvm?
I think I got the entire idea of LLVM wrong... Can I use Clang separately?
Anonymous
Isn't clang a frontend to llvm?
LLVM refers to the whole set of compiler tool chains and yes clang is one of the front ends among many others for other programming languages. It compiles C++ code to the IR language that is then handled by a common backend toolchain.
Vlad
I think I got the entire idea of LLVM wrong... Can I use Clang separately?
It compiles into the middle language that llvm then would use
Vlad
So you were using it all along
Владислав🇺🇦
I guess it will be okay to use it even if the only reason to do so is that I really like the way Clang informs about errors? I may change my mind later on anyway
Владислав🇺🇦
Thank you for your response💫
Anonymous
Hello
Anonymous
@Fai0501
Anonymous
Anyone with. Good book on programming for beginners...
Anonymous
Send me kindly
MᏫᎻᎯᎷᎷᎬᎠ
.
Anonymous
Hi, I want to code something to get me to know how many hours I have worked every month, I am beginner just trying something new, should I do it with the console, like typing the values myself or should in try doing a data base? What do you guys think is easier for a beginner? Thanks in advance.
Steven
You can type in the console and store it in a text format
R
#include <stdio.h> int main(void) { int m=5; int num[5]= {12,13,14,15,16}; int i=0; for(i=5;i>=0;i--) printf("%d", num[i] ); return 0; } I'm trying to reverse numbers Can anyone help me what's wrong with my program?
Hanz
Oh yeah, didnt see that. Im also wrong 😅
佳辉
#include <stdio.h> float add(float , float); float sub(float , float); float mult(float , float); float div(float , float); float add(float num1, float num2) { return num1+num2; } float sub(float num1, float num2) { return num1-num2; } float mult(float num1, float num2) { return num1*num2; } float div(float num1, float num2) { return num1/num2; }
佳辉
Function declaration?
佳辉
😭i really need help
Anonymous
🙄
Sachin
if i declare char str[100] and input str using gets(str) and enter more than 100 characters then try to print str
Sachin
?
Sachin
What will be the output
佳辉
Use flowgarithm
Whats that mean
R
Whats that mean
In the beginning teachers introduced that tool to us It's computer application Install it u will understand
佳辉
Nvm
Anonymous
hey is it possible to access all the members of union at a time?
dipesh
Hey?!
dipesh
Can anyone help me out?
dipesh
I'm confused about return value while using int. Can you explain how does it work when.
Talula
I'm confused about return value while using int. Can you explain how does it work when.
If you return int your function should be int XYZ(void) (or something similar.
dipesh
And what about the return value. How does it work
Anonymous
hey is it possible to access all the members of union at a time?
No. It is Undefined Behavior to access any member field of the union that was not most recently written to. Some compilers do allow this as an extension but it is Undefined Behavior according to the standard.
Talula
And what about the return value. How does it work
Your question isn't clear, what do you mean "how does it work" do you want to understand how it works in assembly or are you saying how does it work in a very basic understanding of how it works.
dipesh
As We give a return value while using int function. I don't know what does it mean. Can you please explain me
dipesh
I'm learning to use user defined function and while making program with argument and with return value. I'm confused about the return value.
Anonymous
I'm learning to use user defined function and while making program with argument and with return value. I'm confused about the return value.
The return value is usually the output of the function. Think of the arguments passed when you call the function as inputs to the function. The return value can sometimes also be used to indicate other things like if an error occured and so on.
Anonymous
always return 0
Talula
I'm learning to use user defined function and while making program with argument and with return value. I'm confused about the return value.
Let us say you passed two variables to add them but you have to return the result so your main caller would get the values… this is how it is done.
dipesh
I got it. Thanks a lot.
dipesh
🤣
Anonymous
in real case error code is not readed, but the output text in stdout - yes