Abed
Does some one have an example about enum please?
RupesH
RupesH
wilson
Roshan
Ernest
Can someone help with C++ basics
Ernest
I want to learn
Anonymous
yo, is the counting in snprintf a side-effect?
Anonymous
like in this: int count = snprintf(strbuffer, sizeof strbuffer, "%d", x);
Anonymous
or calling it a side-effect is just semantics?
Anonymous
like in this: int count = snprintf(strbuffer, sizeof strbuffer, "%d", x);
The assignment to count is not a side effect. Since you can ignore the return value of snprintf (you shouldn't), technically there is no side effect. The actual part of storing the value into the buffer is what is the side effect.
Side effect is usually a semantic issue that relates to pure functions vs functions that impact variables outside of the function.
If a function maintains state internally like say using a static variable, then changes to that variable is also technically a side effect.
Anonymous
ha! knew it
Anonymous
my brain was just defaulting to side-effects=bad
Anonymous
thanks mate
Anonymous
nah, I got what you meant. My side-effects=bad thing comes a book on LISP that I read. Thanks again!
Anonymous
yep
Jollybox.h
Hi everyone
Jollybox.h
I want to read deitel books to learn c++
Jollybox.h
But should İ go deitel c - deitel c++ - deitel c/c++
Anonymous
Hi guys can someone help me with this exercise in C++.
Anonymous
14-Make a program that reads a 10-position vector and checks if there are equal values
and write them on the screen.
Jollybox.h
İ am totally confused, i don't want to spend time to learn outdated c commands or functions so want to start from c++ book but as i see from pdf, it quickly pass the introduction part then cont with classes etc
Lucas
Lucas
It helps
Anonymous
Hi guys can someone help me with this exercise in C++.
14-Make a program that reads a 10-position vector and checks if there are equal values
and write them on the screen.
olli
Rith
Hi guys
Ive a void func
And inside that im going to add something to some arrays
Rith
But when i wanna recall that func
Im gonna getting err
Rith
So im figured out i need to redefine arrays at the end of that func
But i dont know how
Can somebody help me?
Rith
coal
It helps
learning C before C++ makes you use C++ like if it was C
coal
that's how the "C with classes" style originated
Anonymous
Harun
HELLO EVERYONE. Does anyone among us know how to use QT??
Is the usage language c++ or is there a special QT language??
Anonymous
Hey members who has c programming software
Steven
You can imagine Qt as a language that compiles to C++
Steven
it generates codes for you
Harun
Harun
Ler
Hello guys! I'm learning STL and wondering how does function 'swap(vector<T> vec1, vector<T> vec2)' work. I learned from the website that 'swap' does not really exchange the elements of the two objects but exchange their address. So I do a test. It turns out that their address doesn't exchange actually.
Ler
int main() {
vector<string> svec1(10); // vector with ten elements
vector<string> svec2(24); // vector with 24 elements
cout << "&svec1 = " << &svec1 << endl;
cout << "&svec2 = " << &svec2 << endl;
swap(svec1, svec2);
cout << "&svec1 = " << &svec1 << endl;
cout << "&svec2 = " << &svec2 << endl;
return 0;
}
Ler
Here's the result:
&svec1 = 0x7ffee30718b0
&svec2 = 0x7ffee3071898
&svec1 = 0x7ffee30718b0
&svec2 = 0x7ffee3071898
Ler
So what happens when we use swap? Could anyone help?
Ler
BTW, personally I don't think it works by swap elements cause it sounds too inefficient. Am I right?
Ler
But why do both of their address remain unchanged after swapping the pointers?
Ler
Ler
Oh, probably I confused the 'pointer to dynamically allocated array' with '&svec'.
Ler
Swap swaps the pointers but not the addresses of vector objects, is it what you mean?
Ler
Ler
&svec1 = 0x7ffee4be28b0
&svec1[0] = 0x7feba84059d0
&svec2 = 0x7ffee4be2898
&svec2[0] = 0x7feba8405ac0
After swapping:
&svec1 = 0x7ffee4be28b0
&svec1[0] = 0x7feba8405ac0
&svec2 = 0x7ffee4be2898
&svec2[0] = 0x7feba84059d0
Ler
thank you very much.
Ler
I see. thank you!
Ler
One more question, please. Whose address is &svec1?
Ler
I mean address of data member.
Ler
Is it the address of first member(value_type)?
\Device\NUL
Pavel
One more question, please. Whose address is &svec1?
I'm not sure if it's specified.
As I see, vector has standard layout (at least in the implementation that I have) then it should be an address of the first member of the vector object. Imagine it can be something like this
template<typename T>
class vector {
size_t size;
size_t capacity;
T* data;
...
};
So in this case, if you do
vector<int> a;
then &a and &a.size will point to the same location. But if the data pointer is first, then the address of the object is the same with address of the data pointer variable (not the address that it points to).
But that works only because vector has standard layout, if it didn't have (e.g. had a virtual function or destructor), then you couldn't guarantee even this.
Ler
Sid Sun
Not that anyone here is gonna fall for it.. We write C after all
𝕄𝕠𝕙𝕒𝕞𝕞𝕒𝕕
Write a program that receives from the user a real number x and an integer n. Use loop to calculate x. The program for 0 <n must also work correctly.
𝕄𝕠𝕙𝕒𝕞𝕞𝕒𝕕
Loner〽💻
Hello. how can remove escape characters from a string that i acquired from a serial port.
Loner〽💻
and get the integer values?
Loner〽💻
Anonymous
hello guys
Anonymous
i need library or something to controlling Serial port
Anonymous
for c or c++
Talula
wilson
Hi,
I feel confused..... I have this:
typedef void *MdApi;
// and then:
void RegisterMdSpi(MdApi pMdApi);
// is this the same?:
void RegisterMdSpi(void* pMdApi);
// what if:
void RegisterMdSpi(MdApi* pMdApi);
Ahmed
How to add vector<int> vals; with some a positive and some a negative values?
Anonymous
wilson