Carl
Don't know how to
Nameful
Don't know how to
Then look into recursion
itsmanjeet
need help i created a map of unique_ptr std::map<std::unique_ptr<class_1>, std::unique_ptr<class_2>> now while iterating for( auto& [key, val] : mymap) key is const std::unique_ptr<class_1> and val is std::unique_ptr<class_2> i don't know its the right way of doing this, i need key as non const ptr
Anonymous
Keys are always const
itsmanjeet
😟 okkk, got it, i guess vector<pair> work then ?
Vlad
Although you can remove an element and insert a new one
itsmanjeet
can i extract out any pair ?
Vlad
can i extract out any pair ?
Out of where? Elaborate
itsmanjeet
i mean pop out pairs one by one, as i need to move(key)
itsmanjeet
i might need to change the ds to stack<pair> or vector<pair>,
itsmanjeet
for that
Vlad
Why does your map even has unique_ptr as a key to begin with?
Vlad
If you have a unique_ptr you can already get the data that it points to
itsmanjeet
Why does your map even has unique_ptr as a key to begin with?
actually, while writing the ast, all the nodes are unique_ptr, and i am confused with it, need a hash map node, for that i created hash node ast class with std::map<std::unique_ptr<ast::node>, std::uniqu_ptr<ast::node>> hashmap, now for evaluation, i have a eval(unique_ptr<ast::node>); for that i need to do eval(move(key));
Thierry
has anyone experience with Eigen whom i could pm for a question regarding a templated class and an error upon construction "..." does not name a type please message me
Anonymous
Guys
Anonymous
I need some help for C language
Anonymous
Who is free to help me
Anonymous
Try to read
Anonymous
Write a function called “plural” which takes two strings, s1 and s2. s1 will be holding a given noun when the function is called and s2 will be written by this function. The function will copy the plural form of the given noun in s1 to s2 on the basis of the following rules: - If the noun (s1) ends in “y”, remove the “y” and add “ies” For example: fly  flies - If the noun ends in “s”, “ch”, or “sh” add “es” For example: dish  dishes - In all other cases, just add “s” For example: chair  chairs The prototype of the function should be: void plural(char *s1, char *s2); Your function will be used by the following program. Note: Do not use any string conversion and processing functions of the related libraries.
Anonymous
You want us to implement it for you?
Anonymous
So, what's the problem?
I couldn't write the function
Anonymous
Correctly
Anonymous
#include <stdio.h> void plural(char *s1, char *s2); int main() { char string1[80], string2[80]; scanf("%s",string1); plural(string1,string2); printf("%s %s\n",string1,string2); return 0;
Anonymous
I write this but
Anonymous
Plural function how to work
Anonymous
Bad for you
Thanks for the comment
Diego
Damn nice bot reaction
Diego
Just do that, check and return
Anonymous
Anonymous
Fly - flies Chair - chairs
Anonymous
When it realize Y, it must delete last letter and put ies
Diego
okay
Diego
then if(string.Endswith("s")) return //delete y and put ies
Diego
We're not writing code for you dude
Anonymous
I'll try
Anonymous
Again
Dav Wealth ✨
Do you learn c++ here
Vlad
No. We're discussing the curry recipe doncha see
academate
I read rules.
academate
#include <stdio.h> int main(int argc, char const *argv[]) { float a = 1.1, b = 1.2, c = 1.3, d = 1.4, e = 1.1; scanf("%.1f %.1f %.1f %.1f %.1f", &a, &b, &c, &d, &e); if (a == e) printf("%.1f %.1f %.1f %.1f %.1f\nYes", a, b, c, d, e); else printf("%.1f %.1f %.1f %.1f %.1f", a, b, c, d, e); return 0; }
academate
(CORRECT) test case 1 is 1.1 1.2 1.3 1.4 1.1\nYes (INCORRECT) test case 2 is 4.3 5.4 3.1 4.8 50.3 (INCORRECT) test case 3 is 1.1 1.1 1.1 1.1 4.4
academate
I can't find any solution for this.
academate
Tell me if you know thanks.
academate
All test case must be correct.
academate
Only test case 1 is correct i dont know what solution is on 2 and 3 cases.
academate
/get cbook
academate
/get cbook
academate
Oh yes. I fixed my code with books. Just read. Damn it. I just forgot how to encode %f %c %s %d etc.
academate
What are your tests?
test case 1 is only correct. But now all correct in one test. 1 to 3 is correct now.
academate
sorry my bad english. btw thanks for response.
academate
task is must be correct all given test cases.
Vlad
task is must be correct all given test cases.
This is not the task. Tests check your implementation of the task. What is the task itself?
AHMED
#include <iostream> #include <string> using namespace std; class student { public: string name; int *id; student(string a, int b) : name{a}, id{new int{b}} { cout << "Default constructor called.\n"; } student(const student &obj) : name{obj.name}, id{new int{*obj.id}} { cout << "Copy constructor called.\n"; } }; int main() { student student1("Ahmad", 56); cout<<student1.name<<endl; cout<<student1.id<<endl; cout<<"========\n"; student student2 = student1; cout<<student2.name<<endl; cout<<student2.id<<endl; cout<<"========\n"; student1.name="Kamel"; student1.id =new int(12); cout<<student2.name<<endl; cout<<student2.id<<endl; cout<<"========\n"; cout<<student1.name<<endl; cout<<student1.id<<endl; }
AHMED
The output:
AHMED
Default constructor called. Ahmad 0x7c75809010 ======== Copy constructor called. Ahmad 0x7c75809018 ======== Ahmad 0x7c75809018 ======== Kamel 0x7c75809020 [Program finished]
AHMED
I want to change the format of the id in the console to the usual numbers that we use
AHMED
How to do this?
Diego
You mean decimal?
Diego
Why does this have to be so awkward? https://www.geeksforgeeks.org/stdsetbase-stdsetw-stdsetfill-in-cpp/
Tekipeps
hi, while debugging my c code with gdb it shows assembly code when i run layout next how do i make it show my c code please
Diego
Yes
Read up on the article I sent
AHMED
Read up on the article I sent
I added setbase(10) But the same output
Igor🇺🇦
..
Why are you printing pointers to int? What's the point of numbers? Shouldn't it be either cout <<*student.id or just using id as int instead of int*?
AHMED
#include <iostream> #include <string> using namespace std; class student { public: string name; int *id; student(string a, int b) : name{a}, id{new int{b}} { cout << "Default constructor called.\n"; } student(const student &obj) : name{obj.name}, id{new int{*obj.id}} { cout << "Copy constructor called.\n"; } }; int main() { student student1("Ahmad", 56); cout<<student1.name<<endl; cout<<*student1.id<<endl; cout<<"========\n"; student student2 = student1; cout<<student2.name<<endl; cout<<*student2.id<<endl; cout<<"========\n"; student1.name="Kamel"; *student1.id = 12; cout<<student2.name<<endl; cout<<*student2.id<<endl; cout<<"========\n"; cout<<student1.name<<endl; cout<<*student1.id<<endl; }