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
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
Vlad
Anonymous
Anonymous
So that modifications to this value cause a crash
Diego
Anonymous
Anonymous
https://godbolt.org/z/nTbMh8
Diego
Diego
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++?
Alex
#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;
}
}
}
thats valid c++ code
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?
Alex
Nomid Íkorni-Sciurus
yeah, basically, to unlearn C ahah
Anonymous
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
Anonymous
Anonymous
Open a textbook from elementary school to read about rectangles and their characteristics
Anonymous
👍
AmR
I want start learn Assembly. Any one know good tutorial with system number ?.or without.
Anonymous
AmR
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
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
Prince Of Persia
Prince Of Persia
Alex
Alex
Alex
Prince Of Persia
Prince Of Persia
Prince Of Persia
Alex
Prince Of Persia
Alex
same random with same seed
Anonymous
Anonymous
https://man7.org/linux/man-pages/man2/getrandom.2.html
ᣳ⃟ ᣳ⃟ ᣳ⃟ᣳ⃟ᣳ⃟⃟⃟⃟ᣳ⃟ ᣳ⃟ᣳ⃟ ᣳ⃟ᣳ⃟ᣳ⃟ᣳ⃟ᣳ⃟ ᣳ⃟⃟⃟⃟ᣳ⃟ᣳ⃟ᣳ⃟ᣳ⃟ ᣳ⃟⃟ᣳ⃟ᣳ⃟ᣳ⃟ᣳ⃟ ᣳ⃟ ᣳ
hi guys, i have exam now, could you please check if my answers are correct?
Prince Of Persia
std::getline(std::cin,string)
cannot get string more than 4096 Chars in a line