Anonymous
good evening
coal
it does not have as much libraries as node.js, probably yeah
coal
but still there's very good ones, like cpprestsdk (casablanca)
coal
i'd use c++ if the backend had to deal with huuuge workloads, where a language based on an interpreter impl, like php or even javascript, wont be enough (note that node.js uses V8, which performs JIT compilation, making it "almost" as fast as a compiled language)
Anonymous
how to debug child process when using vscode
Anonymous
I create a breakpoint at child process ,when I click debug button ,I can't get that
Eradzh
Has anyone solved skyscraper problem before?
ㅤㅤㅤ
#include <bits/stdc++.h> using namespace std; int main() { string s,t; cin>>s>>t; bool x=true; stack<char> st; for(int i=0;i<t.size();i++){ st.push(t[i]); } for(int i=0;i<t.size();i++){ if(s[i] != st.pop()){ x=false; } } if(x == true){ cout<<"YES"<<endl; } else{ cout<<"NO"<<endl; } return 0; } I have to check is both strings s and t are reverse of each other or not. I tried using stack but its giving error
Anonymous
what meaning of this pane
Leovan
Class attributes call constructor? For example: class MyClass { AnotherClass value; // will call constructor? }
Pavel
Class attributes call constructor? For example: class MyClass { AnotherClass value; // will call constructor? }
If AnotherClass has a default constructor specified, then it will be called when MyClass is constructed
Pavel
can i disable it?
What do you want to achieve by that?
Leovan
What do you want to achieve by that?
Oh, maybe I want something wrong
Pavel
Oh, maybe I want something wrong
Not sure without knowing your problem :) If you want to call a different constructor, you can call in in constructor initializer list of your MyClass constructor, for example
Anonymous
Hello everyone
%Nikita
Hello, guys! I am writing my own console excel engine in C11. There is a moment, when I need to took input like this: margin x 10 It means, that program will set margin(like in CSS) of table to 10 characters. I have some struct table, that has *mx* and *my* fields. If first argument of margin was x, then program need to change t->mx. Otherwise program changes t->my. Here is my function for margin command: void margin(const char * command, table *t){ char* arg1, *arg2; sscanf(command, “margin %s %s”, arg1, arg2); /* processing arguments here */ } So if the first argument equal to "x" then it will change t->mx to arg2: const char *xy = "xy"; char *valid = strchr(xy, *arg1); if (valid == NULL || arg1[1] != '\0') error("invalid syntax"); if (arg1[0] == ‘x’) t->mx = atol(arg2); else t->my = atol(arg2); Cool moment for optimization. It was a small introduction for you to understand where do I found my problem. I decided to not use if else statement, instead I want to use it’s shorter version - ternary operator: ((valid-xy == 0) ? (t->mx) : (t->my)) = atol(arg2); The main question is - why do I get error: main.c:0:0: error: lvalue required as left operand of assignment. I literally don’t understand - if condition equal to zero, it takes t->mx otherwise it takes t->my. So I end up with this: *(&(t->mx) + (valid-xy)) = atol(arg2); Too complicated I think. Then how to fix ternary operator?
Anonymous
Are you the group admin?
YUVRAJ
Plz send me the indian c/c++ group link so that someone can explain me in hindi
Anonymous
I have questions in complier in c
Anonymous
Hello, guys! I am writing my own console excel engine in C11. There is a moment, when I need to took input like this: margin x 10 It means, that program will set margin(like in CSS) of table to 10 characters. I have some struct table, that has *mx* and *my* fields. If first argument of margin was x, then program need to change t->mx. Otherwise program changes t->my. Here is my function for margin command: void margin(const char * command, table *t){ char* arg1, *arg2; sscanf(command, “margin %s %s”, arg1, arg2); /* processing arguments here */ } So if the first argument equal to "x" then it will change t->mx to arg2: const char *xy = "xy"; char *valid = strchr(xy, *arg1); if (valid == NULL || arg1[1] != '\0') error("invalid syntax"); if (arg1[0] == ‘x’) t->mx = atol(arg2); else t->my = atol(arg2); Cool moment for optimization. It was a small introduction for you to understand where do I found my problem. I decided to not use if else statement, instead I want to use it’s shorter version - ternary operator: ((valid-xy == 0) ? (t->mx) : (t->my)) = atol(arg2); The main question is - why do I get error: main.c:0:0: error: lvalue required as left operand of assignment. I literally don’t understand - if condition equal to zero, it takes t->mx otherwise it takes t->my. So I end up with this: *(&(t->mx) + (valid-xy)) = atol(arg2); Too complicated I think. Then how to fix ternary operator?
In C, the conditional operator is never an lvalue expression unlike in C++ where it can be an lvalue expression. That is why your code doesn't work like the equivalent if else condition.
Anonymous
Are you the group admin?
Admins in C/C++ Programming: - @SilhouetteInDark - @roxifas - @anunaym14 - @K11M1 - @I_Interface - - @QNeko - @Ariana1729 - @OxFFFFFFFF - @ollirz - @neko_code - @frame0x01 Note: These are up-to-date values
klimi
@SilhouetteInDark hehe
A
Hi guys could you please help me with this questions of leet code and help me to identify why I am getting a null pointer exception
A
leetcode question 2 Add two numbers
A
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ class Solution { public: ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { vector<int> ans; int carry=0; int val=0; if(l1==NULL && l2==NULL) return NULL; else if(l1==NULL) return l2; else if(l2==NULL) return l1; while(l1->next!=NULL || l2->next!=NULL) { val=l1->val+l2->val+carry; if(val>9) { carry=val/10; val=val%10; } ans.push_back(val); l1=l1->next; l2=l2->next; } while(l1!=NULL) { val=l1->val+carry; if(val>9) { carry=val/10; val=val%10; } ans.push_back(val); l1=l1->next; } while(l2!=NULL) { val=l2->val+carry; if(val>9) { carry=val/10; val=val%10; } ans.push_back(l2->val); l2=l2->next; } ListNode* h=new ListNode(); ListNode* t=h; for(int i=0;i<ans.size();i++) { ListNode* temp=new ListNode(); temp->val=ans[i]; t->next=temp; t=t->next; } return h->next; } };
smene
Hi guys, any resource to build desktop applications in c++?
Kenan
Ok rose thanks
Ольга
Hi, I have a problem, I hope for your help. How to sum elements in variable c? #include <stdio.h> #include <math.h> int main() { int x, n,i,c,z; scanf("%i", &x); scanf("%i",&n); for(i=1; i<=n; i++){ c=pow((x-1),i); printf("%i",c); } return 0; }
alice
1) Write a program that uses the cin method get() to read a line character by character and stores it in a char array. The line is then output in reverse order. Use a pointer, not an index, to address the array elements. Incorporate a class with free store memory allocation for the array of characters that includes a function to reverse the order of the stored character array and print it to the screen and that holds the character array. what is need of using class here i dont understand i know c++ very well but any one can explain what this questions asking for
Vlad
can i disable it?
You can't. Before construction object does not begin its lifetime
Vlad
And only possible way to achieve this in the language is to cast raw memory as an object
Vlad
Needless to say it's UB
Anonymous
Can someone help me ? Idk anything about c programming basics Would someone please tell me what should I do?
Anonymous
Please ?
klimi
Can someone help me ? Idk anything about c programming basics Would someone please tell me what should I do?
like if you wan't to learn it, then you probably need to learn it. What problem are you facing?
Ali
I don't no
klimi
How can I learn ? Can you please tell ? Any tips ?
well need to imerse yourself with it. So watch some videos/courses or read a book. Then (or while you are doing so) try to write something too
Anonymous
well need to imerse yourself with it. So watch some videos/courses or read a book. Then (or while you are doing so) try to write something too
Can you recommend me some videos for new student ? Very new student idk anything about c programming
klimi
Can you recommend me some videos for new student ? Very new student idk anything about c programming
tbh... i cannot. Bisqwit has some nice topics but they are already advanced
Leovan
You can't. Before construction object does not begin its lifetime
Okey, if i use int like attribute and dont init it in class constructor, its will be 0 or UB?
Vlad
Okey, if i use int like attribute and dont init it in class constructor, its will be 0 or UB?
It will be uninitialized. Because default constructor of int is a noop
Vlad
Reading uninitialized memory is UB yes
Aono
Hello guys,,,,I'm Sammy...a beginner..any volunteer to take me through c programming
No Name
Hey, can I send my code here? I have segmentation fault and I don't understand why
Dima
Use pastebin
coal
Hey, can I send my code here? I have segmentation fault and I don't understand why
the rules say you can always send code if you upload it to a pastebin
coal
or any snippets website
No Name
to be honest im pretty new to c, doing a course in the university, any tips to improve my code will be happily accepted https://pastebin.com/TeF9rjxL
Strife
I do not know why all over the internet Python is considered an angel and C ++ is a nightmare and a useless language. These words are funny, but on the other hand, they torment me
Anonymous
to be honest im pretty new to c, doing a course in the university, any tips to improve my code will be happily accepted https://pastebin.com/TeF9rjxL
Accept the dimensions first and create two arrays of that size using dynamic memory allocation. In your code if I give 2 inputs for vector u and vector v and then specify dimensions as 3, your code would fail. Don't use gets for array inputs. Once you know the dimensions, iterate over the array and populate it. Gets is a deprecated function and should not be used. It is unsafe.
Ruslan
Anonymous
I do not know why all over the internet Python is considered an angel and C ++ is a nightmare and a useless language. These words are funny, but on the other hand, they torment me
People who use only C/C++ don't know the advantages Python offers and end up dissing it. People who use only Python have no idea about C/C++ and end up dissing it. And then there are the rest of us who use both the languages and know what the advantages and disadvantages with each are and know when to use what. Python has a unparalleled library support and no other language barring .NET platform languages come close.
coal
nonetheless, C/++ and Python are both tools and they have best use cases
Strife
I have no prejudice against any language Each language has its own audience and goals But it is wrong to call this language a nightmare
coal
it's fair to call any language a nightmare
coal
even python, more specifically django
coal
there's stuff that just doesnt make sense
coal
and python is a "simple language," but that only applies to the syntax
Strife
I can not communicate well with script languages ​​because I have been working on C ++ since day one
coal
with c++, i had many moments where i wanted to quit and i still use it because its a tool
coal
specifically, with batch and au3
coal
then i went with C# which is theoretically compiled
coal
to its own bytecode just like Java does
coal
and then i went to many other programming languages until i ended up with C++ and C
Strife
then i went with C# which is theoretically compiled
I feel the C ++ is still long-lived