Abed
Does some one have an example about enum please?
RupesH
So what should I do?
Plz answer me..
Roshan
Can anyone let me know how can i improve my coding Skills?
Practice questions from Hackerrank etc.
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
my brain was just defaulting to side-effects=bad
I am sorry. I missed a "not" in my original reply which changed the meaning of what I wanted to say. Have clarified it again
Anonymous
nah, I got what you meant. My side-effects=bad thing comes a book on LISP that I read. Thanks again!
Anonymous
nah, I got what you meant. My side-effects=bad thing comes a book on LISP that I read. Thanks again!
Side effects are bad most of the times. It makes it difficult to test your code. You don't have to come from a functional programming background to know that side effects can be harmful. But for things like input and output, they are considered a necessary evil and hence not a cause for worry.
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
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.
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?
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
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
Pavel
HELLO EVERYONE. Does anyone among us know how to use QT?? Is the usage language c++ or is there a special QT language??
The language is still C++ and all general C++ rules apply. Qt gives much more library functions and data containers than STL does. But it has different ideology, and sometimes you will be forced to use Qt stuff instead of STL just not to convert things back and forth. Also some of the libraries (and versions?) have different licensing (if you want to do something commercial, better to research this in advance).
Steven
You can imagine Qt as a language that compiles to C++
Steven
it generates codes for you
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?
Golden Age Of
So what happens when we use swap? Could anyone help?
I guess , as vector is just polymorphic cover on usual dynamic array, it just swaps the pointers
Ler
But why do both of their address remain unchanged after swapping the pointers?
Pavel
But why do both of their address remain unchanged after swapping the pointers?
Why should they change? You get addresses of memory on stack basically. Swap swaps the contents of the vector objects (pointers to dynamically allocated array, sizes)
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
&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.
Pavel
Swap swaps the pointers but not the addresses of vector objects, is it what you mean?
Yes, pointers and also other additional data that vector object can contain (e g. size of vector and size of allocated block of memory)
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
Hey members who has c programming software
Have you read pinned message ?
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.
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?
Anonymous
hello guys
Anonymous
i need library or something to controlling Serial port
Anonymous
for c or c++
Talula
i need library or something to controlling Serial port
https://www.pololu.com/docs/0J73/15.6
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);
Loner〽💻
i need library or something to controlling Serial port
You can use the win32 serial api if in windows platform. Last time I used them they seemed easy.
Anonymous
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);
<quote> typedef void *MdApi; // and then: void RegisterMdSpi(MdApi pMdApi); // is this the same?: void RegisterMdSpi(void* pMdApi); </quote> These two are the same. <quote> // what if: void RegisterMdSpi(MdApi* pMdApi); </quote> This is different. Here the parameter is void** and not void*.
Ahmed
How to add vector<int> vals; with some a positive and some a negative values?
Anonymous
How to add vector<int> vals; with some a positive and some a negative values?
You mean you want to add all the values in a specific vector?