Evil grin
klimi
if i were you i would try QT group
Anonymous
@en_it_chats
Anonymous
If I have a variable declared as follows static const int a = 5 And I want to pass this to a function that has this definition: int dosomething(int* a) Is it bad practice to do dosomething((int*) a) Assume the function never modifies a
Anonymous
Assume C11
Vlad
Shouldn't you just take its address and call it a day?
Diego
If its a constant you won't do much by passing its address either
Diego
int and pointer are the same size In C++ an int usually represents the size of a processor's word, that is, its registry size (1 byte for 8 bit processors, 2 for 16 bit, 4 for 32bit, and so on) And a pointer... is quite literally a word
Diego
So you'll be using as much memory by passing the pointer as copying the int by value, and this int, you can't modify
Diego
Unless you want to use int as a memory offset, that'd be a different scenario entirely But in any case, you should do &MyInt
Anonymous
So that modifications to this value cause a crash
olli
int and pointer are the same size In C++ an int usually represents the size of a processor's word, that is, its registry size (1 byte for 8 bit processors, 2 for 16 bit, 4 for 32bit, and so on) And a pointer... is quite literally a word
There are platforms where uintptr_t is not defined because you can't represent a pointer using an integral value. Leaving exotic platforms aside int is most likely 32 bit even on an 64 bit os Iirc int is 16 bit on some common 8 bit AVR Compilers
Anonymous
https://godbolt.org/z/nTbMh8
Emmanuel
#include<stdio.h> int main () { int a,b; int length; int array[9]; printf ("Enter Length of the array: "); scanf ("%d", &length); printf ("Give the range [a,b]: "); scanf ("%d %d", &a ,&b); printf ("Number from the range[%d,%d]: ", a, b); for (int i = 0; i < length; i++) { scanf ("%d", &array[i]); } for (int j = 0; j < length; j++) { if (array[j] > 0) { printf("%d\n",array[j]); } else{ continue; } } }
Emmanuel
Can someone translate for me into c++?
Nomid Íkorni-Sciurus
thats valid c++ code
I think she means using STL
Anonymous
Hello everybody I'm a c developer, I'd like to start with c++ from c point of view what do you suggest for me?
Nomid Íkorni-Sciurus
Hello everybody I'm a c developer, I'd like to start with c++ from c point of view what do you suggest for me?
not to use C++ unless you have a specific reason to do it. otherwise, to unlearn anything you might have seen with C and to start out again from zero knowledge.
Alex
Hello everybody I'm a c developer, I'd like to start with c++ from c point of view what do you suggest for me?
learn c++ oop; stop using raw pointers, preprocessor; pass val by ref instead of pointer; use c++ lib instead of c
Nomid Íkorni-Sciurus
yeah, basically, to unlearn C ahah
Anonymous
Hello everybody I'm a c developer, I'd like to start with c++ from c point of view what do you suggest for me?
Read Mayer's books Read C++ Core Guidelines Watch CppCon Watch Jason Turner
Ghadah
Hi
Ghadah
I need a group for me + advanced programming in c
Anonymous
Hello, some of us are more advanced than others... I'm just mediocre myself.
Anonymous
Hello everybody
Anonymous
/get cbook
sms
Rose
sms
What is purpose of this grop
Anonymous
Classes in C++: Write the program👉class rectangle
Anonymous
Example: Class circle { Private; double radius: Public: void setRadius(double r) double getDiameter (); double getArea(); double getCircumference(); };
Anonymous
Anonymous
Open a textbook from elementary school to read about rectangles and their characteristics
Anonymous
👍
MᏫᎻᎯᎷᎷᎬᎠ
You were said to write class rectangle and you wrote class circle, really?
Some attributes like height and width of rectangle can be represented with a circle or to be specific "Ellipse"
AmR
I want start learn Assembly. Any one know good tutorial with system number ?.or without.
Prince Of Persia
hi guys
klimi
Prince Of Persia
how to use a safe random number in C++
Prince Of Persia
rand() is not as good as I want
Prince Of Persia
I need something like rand function in java
klimi
rand() is not as good as I want
do you need random for crypto?
Prince Of Persia
I heard about std::mt19937 but it also like rand() for me
HaiNahi
I am making a chess engine anyone joining me?
Prince Of Persia
Prince Of Persia
Alex
any one know?
https://www.cplusplus.com/reference/random/
Alex
any one know?
what do you mean "safe"?
Prince Of Persia
https://www.cplusplus.com/reference/random/
the problem is I need to get random numbers from different ranges each time
Prince Of Persia
what do you mean "safe"?
same random with same seed
Prince Of Persia
use '%' and '+' for range
I have seen a video about why rand() isn't good
Alex
Prince Of Persia
amazing, give a like to this video
https://youtu.be/4_QO1nm7uJs
Prince Of Persia
https://youtu.be/4_QO1nm7uJs
Is not that but same
olli
I need something like rand function in java
if you need secure random numbers use Crypto++, Botan or OpenSSL. I highly doubt the default java random method is secure.
Prince Of Persia
yes, and from the other side he needs same result for same seed :)
😁 what I need is no one understand pattern of my codes
Alex
same random with same seed
Anonymous
https://man7.org/linux/man-pages/man2/getrandom.2.html
Prince Of Persia
same random with same seed
this is a problem that I said
Prince Of Persia
same random with same seed
I said it's not safe be cause ....
ᣳ⃟ ᣳ⃟ ᣳ⃟ᣳ⃟ᣳ⃟⃟⃟⃟ᣳ⃟ ᣳ⃟ᣳ⃟ ᣳ⃟ᣳ⃟ᣳ⃟ᣳ⃟ᣳ⃟ ᣳ⃟⃟⃟⃟ᣳ⃟ᣳ⃟ᣳ⃟ᣳ⃟ ᣳ⃟⃟ᣳ⃟ᣳ⃟ᣳ⃟ᣳ⃟ ᣳ⃟ ᣳ
hi guys, i have exam now, could you please check if my answers are correct?
Jalal
this is a problem that I said
If you use C++ 11 or later, follow this link: https://en.cppreference.com/w/cpp/numeric/random
Prince Of Persia
std::getline(std::cin,string) cannot get string more than 4096 Chars in a line