☬ੴ Bassi
noted from a few groups people join post a video or click bate and then just simply leave.
☬ੴ Bassi
ok i will try hat now i have another telegram account
☬ੴ Bassi
my other account only just joined
Dima
what the heck is going on
Anonymous
Please dont ban my other account it was just to test
Dima
yeah
Anonymous
I have a question about pointer syntax. The programm Works withpointer *ptr and pointer* ptr also. pointer *ptr I see this like "the value of ptr points to is of "pointer" type. pointer* ptr I see this like "there os a pointer ptr of type pointer" But, the First one is correct more than Second one because a pointer is just a int value of a memory address. Is this correct? If not, why not? Appreciate some reference If possible
Anonymous
@Kotheos posso diventare supporter antistormbot
Ajay
what a f*ck are you talkin about?
what are you asking? 😅
Anonymous
/thread
Dima
/thread
/coroutine
Anonymous
/coroutine
Dima
bruh
Dima
/blue_text_must_click
Miret
Hey
Anonymous
Any buddy can explain the logic of rock paper scissor game
Anonymous
Code
V01D
Code
You forgot to share the code
Anunay
Any buddy can explain the logic of rock paper scissor game
This group isn't meant to spoon-feed you. We are here to help you out, but you do need to put in efforts from your side. Show us the code, we can help you improve it or identify points of failure but simply asking for algorithm or code isn't something which would be tolerated here.
Anunay
It's essential that the quality of this chat remains good.
M
Hello guys, just a quick syntax check needed. Will the following line of code execute the function, given the value is TRUE if (!vote(name)) { printf("Invalid vote.\n"); }
Kenny
Your function return true?
Pavel
Hello guys, just a quick syntax check needed. Will the following line of code execute the function, given the value is TRUE if (!vote(name)) { printf("Invalid vote.\n"); }
if vote(name) returns true then the result will be reversed by ! to false and the printf line won't be executed. So it will be executed only if vote(name) returns false
Kenny
! function () same as function() == false
M
Weird. It is an excercise - I am given a code and I should only work on the implementation of functions. However, the given code makes no sense if the function won't be executed for value of 1
Kenny
So it'll execute if function return false
M
maybe take a look at the whole code: #include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int votes; } candidate; // Array of candidates candidate candidates[MAX]; // Number of candidates int candidate_count; // Function prototypes bool vote(string name); void print_winner(void); int main(int argc, string argv[]) { // Check for invalid usage if (argc < 2) { printf("Usage: plurality [candidate ...]\n"); return 1; } // Populate array of candidates candidate_count = argc - 1; if (candidate_count > MAX) { printf("Maximum number of candidates is %i\n", MAX); return 2; } for (int i = 0; i < candidate_count; i++) { candidates[i].name = argv[i + 1]; candidates[i].votes = 0; } int voter_count = get_int("Number of voters: "); // Loop over all voters for (int i = 0; i < voter_count; i++) { string name = get_string("Vote: "); // Check for invalid vote if (!vote(name)) { printf("Invalid vote.\n"); } } // Display winner of election print_winner(); } // Update vote totals given a new vote bool vote(string name) { // TODO return false; } // Print the winner (or winners) of the election void print_winner(void) { // TODO return; }
Pavel
maybe take a look at the whole code: #include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int votes; } candidate; // Array of candidates candidate candidates[MAX]; // Number of candidates int candidate_count; // Function prototypes bool vote(string name); void print_winner(void); int main(int argc, string argv[]) { // Check for invalid usage if (argc < 2) { printf("Usage: plurality [candidate ...]\n"); return 1; } // Populate array of candidates candidate_count = argc - 1; if (candidate_count > MAX) { printf("Maximum number of candidates is %i\n", MAX); return 2; } for (int i = 0; i < candidate_count; i++) { candidates[i].name = argv[i + 1]; candidates[i].votes = 0; } int voter_count = get_int("Number of voters: "); // Loop over all voters for (int i = 0; i < voter_count; i++) { string name = get_string("Vote: "); // Check for invalid vote if (!vote(name)) { printf("Invalid vote.\n"); } } // Display winner of election print_winner(); } // Update vote totals given a new vote bool vote(string name) { // TODO return false; } // Print the winner (or winners) of the election void print_winner(void) { // TODO return; }
What the meaning of the bool returned by vote? If it returns true then what does it mean: that vote was good or bad? By the way, using #define instead of const is not a good idea.
M
This task is absolutely valid and well explained in the assigment
yes, I believe so but I don't get this part of the code
Kenny
What part bro?
M
If I were the one coding, I would've called the vote function after checking the name for validity
M
anyway, I'll just go through the code again to figure out what it's doing
klimi
Um just look at the https://cs50.harvard.edu/x/2020/psets/3/plurality/ where they describe how it should be implemented
Kenny
Oh the vote function must loop on your candidates array and look if the vote == any candidate name, if both are equals then increment the votes counter
M
Oh the vote function must loop on your candidates array and look if the vote == any candidate name, if both are equals then increment the votes counter
yes, exactly. but this will break the rules of only changing the functions' implementation. I cannot add / change code
Kenny
Yes, you should implement that i said on the vote function man
M
I understand that but the point is - I don't see where the function's called. It won't execute if the name is wrong, right. But if it's correct, it still won't.
Kenny
Sure, you must see in the function if the name is invalid, If it is then don't increment the vote counter
M
yes, this is super clear. but where in the main function do we call the vote function? that's my question..
Kenny
When you are looping on all voters
Wojak
/ban all 3 messages posted by user were cringe
Hey, what if he didn't know good English or lacked communication skills or was just an introvert who didn't know how to communicate? And was trying hard against all this looking out like an imposter who personified himself as cringe? 🤔🤔
Wojak
Jk
Wojak
Having DEQUE in STL, can we replace it as a permanent substitute to stack due to push_front or push_back?
Wojak
Having DEQUE in STL, can we replace it as a permanent substitute to stack due to push_front or push_back?
I mean if DEQUE can perform both stack and queue operations, is it fine to use it at place otherwise stack would be used or would it be a bad Practice to do so
Anonymous
it creates a stack interface by using the interface of another container (default is std::deque, but you can pass it any container that supports back(), push_back(), and pop_back() like std::vector or std::list)
Wojak
That's what I'm asking if it is a bad practise to use Double-ended queue as stack or queue because we are initializing just one container and it can be used multiple times for multiple operations
Wojak
otherwise we would need different containers to act as a stack or queue
Anonymous
That's what I'm asking if it is a bad practise to use Double-ended queue as stack or queue because we are initializing just one container and it can be used multiple times for multiple operations
that would be highly dependant on the particular code you are writing and its requirements. but "used multiple times for multiple operations" sounds like a bad idea in general.
Wojak
Okkk... Anyone else who would like to show some light upon this ?
Dima
maybe you need a circular buffer?
Wojak
maybe you need a circular buffer?
Never heard about this, got a basic idea by googling it. Can you hint a little about circular buffer's use in this scenario?
Dima
audio buffer
Dima
well its kinda complex, but I’ve used it for audio streaming
Wojak
And how can that be used here ?
Wojak
in context to stack,queue and deque
Dima
you put something in the beginning, while the other thread is reading it from the end, but its circular, so it doesnt get oveflowed
Dima
the key difference I think is that it can’t overflow
Dima
it simply moves end pointer to the start
Wojak
Great. Thanks
V01D
int **ptr; = ptr is a pointer to a pointer to an int - Why would I use this?
V01D
Remove using statement, heard it's bad practice.
Anonymous
Global usings are bad practice, yes
Anonymous
I used that as a matrix
It should not be used as matrix in C++
V01D
I used that as a matrix
What exactly does that mean?
Anonymous
This is not a good code since you're using unstable boost API (boost::beast::core::detail)
Anonymous
why?
Because there's at least std::vector
Kenny
What exactly does that mean?
i used it as a 2d array. Normal: int matrix[N][N]; I did int **matrix; Because i was reading a file, and it gave me the N parameter
Kenny
Oh, so ** is just a 2D array?
It's a pointer to a pointer bro
V01D
Yeah, but I don't get why it exsists.
Anonymous
/get cppbookguide