Suka
I will try
goodluck
Crow
Let me have a try
der ðiβüśüɾę
der ðiβüśüɾę
WOW!!!
der ðiβüśüɾę
IT WORKS! THANKS A LOT
Crow
Anytime
der ðiβüśüɾę
Anytime
Hmm.. How i can compile for x32 windows system?
der ðiβüśüɾę
My dad have windows 7 x32 bits
der ðiβüśüɾę
I am testing the program on his laptop
der ðiβüśüɾę
try g++ -m32 for 32bit
Ok, i will tried
der ðiβüśüɾę
On void needs download glibc-devel-32bit
der ðiβüśüɾę
/usr/bin/ld: skipping incompatible /usr/lib64/gcc/x86_64-unknown-linux-gnu/10.2.1/libgcc.a when searching for -lgcc /usr/bin/ld: cannot find -lgcc collect2: error: ld returned 1 exit status
Suka
On void needs download glibc-devel-32bit
i believe you need mingw 32bit package. cmiiw
der ðiβüśüɾę
👌
der ðiβüśüɾę
Alreade installed
der ðiβüśüɾę
Suka, your name soundly like russian swear word сука))
der ðiβüśüɾę
Сука — bitch
Suka
Suka, your name soundly like russian swear word сука))
yeah i know hehe. in indonesia it just "like" like in i like pizza hehe or also means happy hehe
Suka
let me tryit when iam back from "warkop" (coffee cafe) hehe
Suka
funny
hehe
Anshul
string s; getline(cin,s); char *p=strtok((char*)s.c_str()," "); char a[10]; strcpy(a,p);
Anshul
in my code i get a segmentaion fault, can anyone tell why
Anonymous
string s; getline(cin,s); char *p=strtok((char*)s.c_str()," "); char a[10]; strcpy(a,p);
Read the documentation for strtok and find out what it does to its first argument. It is Undefined Behavior to change a const char* string.
Anonymous
If you are coding in C++, use C++ methods rather than using C functions.
Anshul
Read the documentation for strtok and find out what it does to its first argument. It is Undefined Behavior to change a const char* string.
strtok takes it first arguement as char *. here i am converting const char * to char *, i know this is not right but as strtok doesn't make any changes to it's first parameter so there's no problem in it.
Anshul
If you are coding in C++, use C++ methods rather than using C functions.
i don't know what does that mean. i followed a tutorial and that uses strtok
Anonymous
Anonymous
i don't know what does that mean. i followed a tutorial and that uses strtok
Read the notes section in the above image and tell me if strtok will change str or not. In future use C++ style in C++ code. If you must use C, atleast read good documentation rather than following online tutorials like tutorialspoint, geeksforgeeks and other similar sites.
Anshul
So if the string is say "a b c" strtok will convert it to "a\0b\0c\0"
Anonymous
i don't know what does that mean. i followed a tutorial and that uses strtok
Just for reference, any header that begins with a 'c' is most likely a C header. You should seldom use them in C++ code barring very fee exceptional circumstances. They are there for historical reasons. strtok is defined in the header <cstring>. It is the C++ version of the C header file string.h. C++ string offers many methods in the string class which can do this much faster than strtok and in a safer way.
Anonymous
What should I use instead of strtok
Check the documentation for std::string. You can use stringstream as well.
Anshul
Check the documentation for std::string. You can use stringstream as well.
Ok I will check. Documentation are on cplusplusrefrence right?
Anonymous
So if the string is say "a b c" strtok will convert it to "a\0b\0c\0"
Yes. But the last '\0' is not written by strtok. It was originally there. Like I said before changing the string returned through c_str is undefined Behavior. You can use data() method of string class instead. This would work in place of c_str.
artemetra 🇺🇦
hi guys, starting a new project i'm looking for a 2d graphics library and a GUI one in C++ i don't want anything too low level like OpenGL (i just need to draw points, build connections between them, display grids, etc.), so i think of using SFML. i've also heard of raylib but afaik it's more designed for games rather than applications for GUI, i know a little bit of Qt, but wxWidgets is also in consideration final question: is SFML and Qt easily merged? I found very few information on linking Qt and SFML together in one app. if not - what GUI lib i should use, then?
Prince kumar
While there is bro
Prince kumar
See carefully
Anonymous
I can't answer such subjective questions. It varies from person to person. Also I am not sure how good the translation of the book to your language is. I learned C++ using C++ Primer (4th edition - C++03 version) in English and hence I can vouch for it. Can't say much about your effort to read it in English. You have to decide on your own.
Anonymous
Which is why I said I can't comment on the book's translation. I haven't read it and I don't know how accurate it is.
Anonymous
If the translation is by some guy who is a known name in the C++ community from your country, then by all means go ahead. You can look up the translator's name and find his reputation. A decent Stackoverflow profile or a GitHub page with many starred projects is usually a good indicator
Anonymous
Good for you.
Ehsan
any recommendations for gui libraries?
Anonymous
#Puzzle char a = 'a'; a.~char(); //Compiler Error using Char = char; //typedef char Char; char a = 'a'; a.~Char(); //Ok Why does C++ allow the latter but not the former?
$@m
Can anyone please help me in downloading mingw? Pleas
Anonymous
Can anyone please help me in downloading mingw? Pleas
Follow the instructions on this page: https://www.msys2.org/
Anonymous
I am guessing is that related to destructor
In both the codes, an attempt is made to call the destructor. So I don't understand what you are trying to say.
Captain
In both the codes, an attempt is made to call the destructor. So I don't understand what you are trying to say.
Yeah I meant constructors and destructors start with a Cap So thats my answer I am not confident on this one.
Anonymous
Yeah I meant constructors and destructors start with a Cap So thats my answer I am not confident on this one.
Not really. class a{ public: a() = default; ~a() = default; }; This code would work fine.
Anonymous
Can someone explain how this works? https://docs.microsoft.com/en-us/cpp/standard-library/overloading-the-output-operator-for-your-own-classes How can we define the function ostream& operator<<(ostream& os, const Date& dt) if it's not already declared inside the ostream class? And why does it have an ostream& os parameter when it only needs the Date& dt to display the date, and can return *this to support chaining?
Suka
#Puzzle char a = 'a'; a.~char(); //Compiler Error using Char = char; //typedef char Char; char a = 'a'; a.~Char(); //Ok Why does C++ allow the latter but not the former?
perhaps compiler allow the latter because it use custom alias not using built-in datattype? or perhaps c++ by default create deconstructor function for any type except for primitives? hehe cmiiw
Anonymous
perhaps compiler allow the latter because it use custom alias not using built-in datattype? or perhaps c++ by default create deconstructor function for any type except for primitives? hehe cmiiw
But the question is why? Why can't the compiler figure out that Char is an alias for char and disallow that too? It is easy to do that.
Anonymous
Can someone explain how this works? https://docs.microsoft.com/en-us/cpp/standard-library/overloading-the-output-operator-for-your-own-classes How can we define the function ostream& operator<<(ostream& os, const Date& dt) if it's not already declared inside the ostream class? And why does it have an ostream& os parameter when it only needs the Date& dt to display the date, and can return *this to support chaining?
It obviously needs an ostream parameter to know which output stream you want to print the object to. It returns the same ostream object by reference (because ostream objects cannot be copied) to support chaining. operator<< doesn't have to be a member of ostream because it doesn't have to access the internals of ostream class. It only needs to access the internals of the class that you are defining. If the operator<< were a member of ostream, then the class itself would be unbounded as it has to support any class type that can be defined at any point of the time in future. How would you define this method? If you think templates would be the solution, then there are 2 issues. 1. It is not possible to define a template method that can print any datatype because the template writer has no way of knowing what your datatype is and can't predict the internals of your class and can't access them either. 2. Templates can't be virtual. Only a class writer can decide how to print his class and not the ostream library writer. You overload operator<< for your class and make it a friend function so that it can access the internals. This method must be declared in the same namespace in which your class is defined. It will then be found by ADL.
Anonymous
Because you have declared char as a class and ~Char() is a destructor called.
I have not declared char as a class. It is a built-in type.
Talula
I have not declared char as a class. It is a built-in type.
(I maybe totally off on terminology) You are defining Char as char, which makes Char as class with char as it's definition, so you have a destructor for it now.
Talula
Sorry been out of college for 12 years now so terminology is going to be bad and totally off.
Anonymous
(I maybe totally off on terminology) You are defining Char as char, which makes Char as class with char as it's definition, so you have a destructor for it now.
No. Char is just a typedef or an alias. In most of the compiler implementations Char will be replaced by char in the compilation phase. And yet this code is allowed.
Talula
Tried it with int and it worked too.
Anonymous
Seems like using keyword makes turns everything in to class like...
No it doesn't turn into a class. Like I said it is an alias. So a.~Char() will be replaced by a.~char() but still allowed to compile There is a reason why this is allowed. I want to see if someone can give me the reason.
Anonymous
Tried it with int and it worked too.
Yes it will work for all built-in types