Ashish Bhushan
I mean why everyone ask that i want to learn c or c++ ....only way to learn is to start by yourself
Ashish Bhushan
Internet has everything you need
Ashish Bhushan
Everything you can find on the web....from books to videos
Anonymous
ohhkayyy. . . let me write because i understand that way, so my 0 100 0000 has become 1 000 0000. . . 1s compliment: 111 1111, adding one, 000 0000!! 1 000 0000!!!! it is indeed -128!! woww its simple, thanksssss !!
MᏫᎻᎯᎷᎷᎬᎠ
How similar is Cpp to JavaScript and Php? I am a beginner, I have learned web development, I wanna learn programming languages like Cpp and Java, will my prior knowledge on JavaScript and Php help me to learn it? How similar are they? https://redd.it/g5h33p @r_cpp
MᏫᎻᎯᎷᎷᎬᎠ
Just a little bit or Maybe NO
MᏫᎻᎯᎷᎷᎬᎠ
Most likely they will fall into the same trap when C dev migrate to C++
MᏫᎻᎯᎷᎷᎬᎠ
At least C has a bit of type safety
Dima
lol
MᏫᎻᎯᎷᎷᎬᎠ
Well Both of us can't judge whether it's easy to begin with 0 knowledge or a web background
MᏫᎻᎯᎷᎷᎬᎠ
I myself started C++ at first at the time I didn't know what IDE is I did write on papers tho XD
Hermann
Just another update right?
MᏫᎻᎯᎷᎷᎬᎠ
Got nothing to say then :)
Anonymous
hello, please, can someone can explain the difference between for(auto&& stuff : stuff_container) and for(auto& stuff : stuff_container)?
Sasuke
This code works #include<iostream> using namespace std; int f1(){ int m = 0; return m; } int main(){ int x = f1(); return 0; } But this isn't why? #include<iostream> using namespace std; int *f1(){ int m = 0; return &m; } int main(){ int * x = f1(); return 0; }
Sasuke
And asking why one snippet works and other isn't
Anonymous
So can we return the m variable it also goes out of scope?
you are returning a copy of m, not m itself (first code)
Anonymous
yep, but what could be better use in a general case like that?
Sasuke
Ah I see
Sasuke
Thanks both of u
Anonymous
yes, but I'm thinking about only similar for loop on containers, what could be better use?
Anonymous
👍, many thanks
Sampurna
Can someone solve this please
I_Interface
Can someone solve this please
If u cant solve even this, programming isn't urs 100%.
Anonymous
Can someone solve this please
-= is the operator. the question doesn't make sense
Anonymous
Hello everyone
zelika
hi
Anonymous
And asking why one snippet works and other isn't
so this would work, #include <stdio.h> int* fun(){ static int m = 88; return &m; } int main(void) { int* x = fun(); printf("%d\n", *x); return 0; }
Anonymous
no no no not at all. unless there are some mistakes in my code then u can point out, like maybe a bad practice... would appreciate that
Anonymous
Hey Guyzzzzz I am the bigenginer in C plz suggest me that this channel is good
Anonymous
For me
Anonymous
Yes it is u should use dynamic storage instead of static variables
ooo dynamic never heard of that, but i will, sooner or later learn! can u give me a small sniff of it, like what will happen in the above code in case of that dynamic thingy... i hope this is not going offtopic.
Sasuke
Int *m = (int *) malloc(sizeof(int));
Sasuke
Coz "static" variables have file scope it is more error prone it has higher chances of getting changed elsewhere in the program unintentionally.
Anonymous
in current compilers/platforms without optimization, yes, that works
however that's an undefined bahavior and you MUST never write a program with undefined behavior
Sasuke
It is considered bad practice to use global variables unless to much necessity
Dima
It is considered bad practice to use global variables unless to much necessity
if your app is single threaded then its okay but thread_local is good for global variables
Sasuke
oh, my bad. I thought it was an auto variable
In C auto means automatical scope so it's is still not undefined.
Sasuke
Why that static variables isn't file scope? Static variables are supposed to be file scope?
Sasuke
What new meaning?
Sasuke
Oh then whats the scope of a static variable in a function or a block?
Sasuke
Type deductions in c++03 not C all standard and the code guy wrote is in C coz of stdio.h file and that's what I told it has auto scope which is block scope u ar saying. And why the behaviour is undefined? auto int m = 0; has a defined behaviour we just defined it as 0
Sasuke
If lifetime is of the program then we can return the address of that variable right?
Sasuke
Yes I understand auto int m; and int m; are same thing
Sasuke
I think You are confused
Sasuke
Yes in this sense you are right
Anonymous
he said mutalib had stdio.h which meant C. i don't think there is a confusion
Sasuke
he said mutalib had stdio.h which meant C. i don't think there is a confusion
Yes and C's auto variable means auto scope not type deduction
Sasuke
Yes coz I misunderstood in what sense he is saying it undefined my bad
Sasuke
😂😂😂
Sasuke
Chill
Anonymous
oh, my bad. I thought it was an auto variable
he thought the static was auto (automatic storage duration)
Anonymous
In C auto means automatical scope so it's is still not undefined.
you thought "oh, my bad. I thought it was an auto (type deduction) variable" and explained automatic storage duration
Anonymous
ye so the argument became "auto n = 5; when compiler doesn't support type deductions is undefined" which is true. but the other side was still talking about auto int n = 5;
Sasuke
Not again 😂😂
Sasuke
+1
Anonymous
omg what has happened
Anonymous
lul
Anonymous
can i do sticker spam before purge?
Sasuke
omg what has happened
Haha u did all this
Anonymous
Haha u did all this
really???? T_T