Chiranjeevi
One more thing, i have 5 elements in the map, but after inserting them into set using comparator function i have only 2 elements in the set. Why is that? My main aim is to sort them, but i am losing elements here.
Anonymous
One more thing, i have 5 elements in the map, but after inserting them into set using comparator function i have only 2 elements in the set. Why is that? My main aim is to sort them, but i am losing elements here.
Because set contains unique elements only You are trying to sort key-value pairs of the map by value part using std::set and custom comparator But in the map your keys have only of two value: 1 or 2 That's why you have 2 elements in the set
Anonymous
Use std::multiset or std::vector with std::sort
Chiranjeevi
Thanks, but i thought the uniqueness is checked by the pair as a whole, never thought the uniqueness is checked using only value.
khyrull
hello guys
MᏫᎻᎯᎷᎷᎬᎠ
std::array is code-bloat
Ilya
Thanks, but i thought the uniqueness is checked by the pair as a whole, never thought the uniqueness is checked using only value.
The map u use before it, also can contain only unique keys, but you have two '2' keys
Anonymous
hey
Anya
Hello i wanna start programming with c who can help me?
Francisco
std::array is code-bloat
But I'd use it rather than old C-arrays
MᏫᎻᎯᎷᎷᎬᎠ
But I'd use it rather than old C-arrays
Unless there are std::array with various sizes across your source code
Francisco
Unless there are std::array with various sizes across your source code
If I know the size at compile time, I'll surely use std::array
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Yeah it's a warning Pretty enough
Mauryain™️
/rules
/rules
MᏫᎻᎯᎷᎷᎬᎠ
And very small cases Where bound safety is guaranteed
Francisco
Also, clang-tidy warns when using C-style arrays, and recommends std::array
MᏫᎻᎯᎷᎷᎬᎠ
Also, clang-tidy warns when using C-style arrays, and recommends std::array
What arises this question is that while I was skimming through Rust, it's said that its built-in array is not code-bloated
Anonymous
C-style warns you from variable sizes
I thought C++ didn't have VLAs
MᏫᎻᎯᎷᎷᎬᎠ
Anonymous
vla = variable-length arrays
MᏫᎻᎯᎷᎷᎬᎠ
I thought C++ didn't have VLAs
Well The compiler generates warnings lol
Anonymous
Also, what do you mean when you say std::array is code bloat?
MᏫᎻᎯᎷᎷᎬᎠ
Also, what do you mean when you say std::array is code bloat?
For example std::array<int, 5>, std::array<int, 6> and std::array<int, 10> Are all independent classes
MᏫᎻᎯᎷᎷᎬᎠ
Everytime, an instantiation of class happens
Anonymous
oh
MᏫᎻᎯᎷᎷᎬᎠ
class array<int, 5>{}; class array<int, 7>{}; class array<int, 10>{};
MᏫᎻᎯᎷᎷᎬᎠ
I mean Wtf No body wants that
Francisco
I mean Wtf No body wants that
And what do you propose? The good thing about std::array is its interface and compatibility with the rest of the containers. Also, the size must be known at compile time, otherwise it's an error
Francisco
And it doesn't decay to a pointer
Rashi
#include<stdio.h> int main() { int t,j; long int n,i; int s[100000][10]; scanf("%d",&t); while(t--){ scanf("%ld",&n); for(i=1;i<=n;i++){ for(j=1;j<=10;j++){ scanf("%d",&s[i][j]); } } for(i=1;i<=n;i++){ for(j=1;j<=10;j++){ printf("%d\n",s[i][j]); } } } return 0; }
Rashi
Hello everyone, I am facing problem in printing this 2-D array..The last element is not getting printed correctly .. Can anyone help?
Rashi
#include<stdio.h> int main() { int t,j; long int n,i; int s[100000][10]; scanf("%d",&t); while(t--){ scanf("%ld",&n); for(i=0;i<n;i++){ for(j=0;j<9;j++){ scanf("%d",&s[i][j]); } } for(i=0;i<n;i++){ for(j=0;j<10;j++){ printf("%d\n",s[i][j]); } } } return 0; }
Rashi
This code is also giving same output
Rashi
problem is occuring in only those values which are starting with 0
Rashi
For example , If I enter 1 4 1110001101 1010101011 0000000011 1111100000 0000111110 As input , then first second and fourth string is printing fine , but not third and fifth
01000001011011010100000101101110
Is this from on going contest?
Anonymous
what's the output? and what were you expecting?
Anonymous
you never actually mentioned what the program was supposed to do, just that there's a problem.
01000001011011010100000101101110
It's from on going contest
01000001011011010100000101101110
Ask for link of the Problem
Rashi
#include<stdio.h> int main() { int t,j; long int n,i; int s[100000][10]; scanf("%d",&t); while(t--){ scanf("%ld",&n); for(i=0;i<n;i++){ for(j=0;j<10;j++){ scanf("%d",&s[i][j]); } } for(i=0;i<n;i++){ for(j=0;j<10;j++){ printf("%d\n",s[i][j]); } } } return 0; }
Rashi
This is the code
Rashi
1 5 1110001101 1010101011 0000000011 1111100000 0000111110 This is input
Rashi
1110001101 1010101011 0000000011 1111100000 0000111110 This is expected output
Rashi
1110001101 1010101011 11 1111100000 111110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Rashi
This is what i am getting
I_Interface
This is what i am getting
Names of variables - terrible. int s[1000000][10]; - terrible. Code reading - terrible.
Dima
read the rules
I_Interface
What the hell
Super modern code. xd
Anonymous
>:(
Anonymous
/command
Anonymous
!ban
Rashi
Sorry . I will never ask anything here from now .
Dima
Sorry . I will never ask anything here from now .
you can but if you do it after reading the rules
Ander
for get parameters specify them in the first line like GET /?a=3;b=5 HTTP..., for post add a Content-Type header, set it to application/x-www-form-urlencoded, a Content-Length header, then at the end of the request add the post parameters in the same format as the get parameters
hi Jay; I am trying your suggestion for GET requests. I am using this code: "GET /botMYTOKEN/sendMessage?chat_id=MYCHATID&text=SENTFROMCPROGRAM HTTP/1.1\r\nHost: http://api.telegram.org \r\n\r\n" Hoewer does not work, would you make any changes? Thanks a lot!
Anonymous
someone with some revision notes and papers on c++ program i go through please in preparation for my exams
Anonymous
Anonymous
hi Jay; I am trying your suggestion for GET requests. I am using this code: "GET /botMYTOKEN/sendMessage?chat_id=MYCHATID&text=SENTFROMCPROGRAM HTTP/1.1\r\nHost: http://api.telegram.org \r\n\r\n" Hoewer does not work, would you make any changes? Thanks a lot!
just tried it, with that you'll get 400 bad request. change the host to just api.telegram.org after that you'll get a redirect to the https version of the api. so: "GET /botMYTOKEN/sendMessage?chat_id=MYCHATID&text=SENTFROMCPROGRAM HTTP/1.1\r\nHost: api.telegram.org\r\n\r\n"
Ketan
Hi
Pradeep Kumar
Hii
Ander
just tried it, with that you'll get 400 bad request. change the host to just api.telegram.org after that you'll get a redirect to the https version of the api. so: "GET /botMYTOKEN/sendMessage?chat_id=MYCHATID&text=SENTFROMCPROGRAM HTTP/1.1\r\nHost: api.telegram.org\r\n\r\n"
I have tried as you said, but I get a I get a HTTP/1.1 301 Moved Permanently response so I imagine that the code is correct and the error is somewhere else. I will have a look. Thanks for your support!
Anonymous
there isn't an error, you just can't use the api without https
H̲i̲L̲e̲v̲e̲l̲
Also you can use telegram api without webhook, through the long poll
Ander
Also you can use telegram api without webhook, through the long poll
Can you specify more please, I'm new with C. Thank you
H̲i̲L̲e̲v̲e̲l̲
Can you specify more please, I'm new with C. Thank you
https://unnikked.ga/how-to-create-your-custom-telegram-bot-using-the-long-polling-technique-c8e925ccb1c6
H̲i̲L̲e̲v̲e̲l̲
But it's c#
Anya
what is the best way to start c? which source or book or video tutorial?