Anonymous
C++/CLI is not C++
Deni
Anonymous
Deni
What?
There are too many Memory leaks hahaha
Mariia
Hello everyone! Tried to create a code for fractional arithmetic ("+" - addition, "-" - subtraction, "*" - multiplication, "/" - division). Doesn't work((
#include <stdio.h> //chisl = numerator, znam = denominator, znak = sign
struct Drob {
int chisl;
int znam;
int znak;
};
Drob A, B, C;
int x, y, z;
int chisl, znam, chisl2, znam2;
int znak;
int a, b;
int main() {
scanf_s("%d%d", &A.chisl, &A.znam);
scanf_s("%d", &znak);
scanf_s("%d%d", &B.chisl, &B.znam);
C.chisl = A.chisl * B.chisl;
C.znam = A.znam * B.znam;
printf("%d", C.chisl, C.znam);
return 0;
}
Mariia
incoming data:
-3 1/6
+
2/4
output data:
-2 2/3
Mariia
what is wrong here?
ברני
ברני
Above the int main
Mariia
I used structures, what and how can I change it?
Mariia
First time I've used it
Артём
Hello everyone! Tried to create a code for fractional arithmetic ("+" - addition, "-" - subtraction, "*" - multiplication, "/" - division). Doesn't work((
#include <stdio.h> //chisl = numerator, znam = denominator, znak = sign
struct Drob {
int chisl;
int znam;
int znak;
};
Drob A, B, C;
int x, y, z;
int chisl, znam, chisl2, znam2;
int znak;
int a, b;
int main() {
scanf_s("%d%d", &A.chisl, &A.znam);
scanf_s("%d", &znak);
scanf_s("%d%d", &B.chisl, &B.znam);
C.chisl = A.chisl * B.chisl;
C.znam = A.znam * B.znam;
printf("%d", C.chisl, C.znam);
return 0;
}
'+' is not int, it cannot be read this way.
Read it as char, or enter smth like +1 / -1 instead
Igor🇺🇦
Mariia
okay, will watch them, thank you all!)
Артём
I'm working with C++/CLI. I have a template metafunction, and need to check whether there is a specific member variable in classes which objects are passed as arguments. I have googled solutions and they work well with classes written by me, but for some reason they don't work for objects like System::Windows::Forms::TextBox^ .
Here is an example, how do I detect member variables named Value :
template <typename T, typename = int>
struct Has : std::false_type { };
template <typename T>
struct Has <T, decltype((void)T::Value, 0)> : std::true_type { };
Usage:
template <class TComponent>
void f(TComponent comp) {
if constexpr (Has<TComponent>::value) {
// ...
} else {
// ...
}
}
Артём
How do I fix it? How to check Windows::Forms components, whether they have a specific member variable?
Joo
Hello please can someone tell how to add or subtract three more numbers in cpp
Joo
And whats the enumeration type for?
Pavel
Rudrapratap
Does someone has c++ of sumita arora
Yazidi
void print_extra (string *kids_ptr , int kids , Date selection )
{
cout << "Kids' names: ";
for (int i=0; i<kids; i++)
{
cout << *(kids_ptr+i) << ", ";
}
cout << "\b\b";
cout << endl;
cout << "Date: " << selection.day << "/" << selection.month << "/2021";
}
Yazidi
Please anyone helps me to solve this problem with pointer
Yazidi
It doesn't work well when I entered input more than 1 for kids_ptr
Vlad
Vlad
Also consider using containers instead(vector)
Vlad
And const correctness would be neat too(print function that takes non const parameters is kinda bogus)
Al
Al
plus use kids_ptr++ to scan your string
Al
kids car is supposed to be the length of your string ... hard to see errors if the rest is not included
Al
*var
Al
easy you have a segmentation fault here
PaAaAria
https://hastebin.com/uziyicedig.cpp
hi everybody, in this code while doesn't work accurately
I mean it starts an infinite loop and I don't the reason, would anybody help me to fix it?
914
guys, how to generate REAL random number?
914
used srand((unsigned)time(NULL)); but still got not actually random number
crt
either use /dev/random
914
with rand() % number
crt
or if that's identical to urandom get a hardware TRNG card
914
ty
olli
guys, how to generate REAL random number?
if you use C++, you might prefer std::random_device and std::mt19937 over rand() e.g. like this for a dice
#include <random>
static std::random_device rd;
static std::mt19937 rng{rd()};
int dice()
{
static std::uniform_int_distribution<int> uid(1,6);
return uid(rng);
}
914
wow thanks a lot
YUSUF
I want to learn machine learning in c++ can any one recommend me any book plz
klimi
Pavel
guys, how to generate REAL random number?
Simple reading
https://diego.assencio.com/?index=6890b8c50169ef45b74db135063c227c
More complex reading
https://www.pcg-random.org/posts/cpp-seeding-surprises.html
UPD: replaced the first link with more related to the topic
Aj
In unordered_map<int ,int> what is the default value of an key is it garbage or zero ?
Anonymous
Hello everyone
Anonymous
I'm a beginner at this
Anonymous
Is there are some sources of C++?
Akku
Hadaward 'Solly'
Anonymous
Hadaward 'Solly'
#notes
Hadaward 'Solly'
/saved
Anonymous
What is this?
Hadaward 'Solly'
"List of notes in C/C++"
Anonymous
What is notes?
Anonymous
Like notepads?
Hadaward 'Solly'
basically a compilation of interesting reads/resources
Hadaward 'Solly'
#hownottoask
Anonymous
Anonymous
I'm asking about C++ resources anybody can help?
Hadaward 'Solly'
#cpp
Anonymous
#cplusplus
Anonymous
Thank you
Hadaward 'Solly'
you're welcome
Aakash
Aj
Aj
Ammar
/get gcc9
Ammar
/get stop_teaching_c_as_cpp_preamble
Aakash
Thankss☺️
In this case NULL to key/value is assigned as value/&key !!
You may godbolt🙃
std::unordered_map<std::string, int> umap;
umap["value"];
Corrected!
Anonymous
hai
Mahsun
#noendl
Артём
Show us how you are calling this function.