Ramil
And the cost is called "zero cost"
that still giggles me even today ngl
Anonymous
In terms of development efficiency, C++ is relatively backward
\Device\NUL
c with classes sounds good
C++ isn't C with Clasess
Abhishek
c with classes sounds good
originally yes... but it a lot more than that now
Demian
Hello, could you help me can I move a pointer of the file to specific line if lines have different length? example of file name:x1 foundationYear:2000 tax:1 legalAddress:leg1 street, actualAddress:act street name:x2 foundationYear:2001 tax:2 legalAddress:SFSDFS street, actualAddress:act2 street name:x3 foundationYear:2002 tax:3 legalAddress:BLAH BLAH street, actualAddress:act3 street
Anonymous
Hello, could you help me can I move a pointer of the file to specific line if lines have different length? example of file name:x1 foundationYear:2000 tax:1 legalAddress:leg1 street, actualAddress:act street name:x2 foundationYear:2001 tax:2 legalAddress:SFSDFS street, actualAddress:act2 street name:x3 foundationYear:2002 tax:3 legalAddress:BLAH BLAH street, actualAddress:act3 street
You will have to start from the beginning everytime you want to reach a random line. Is that alright? And by "specific line", I assume you want to reach a particular line number. I would suggest storing the file in a vector (or a data structure like a map if you need to index based on keywords), if you need to do multiple queries of this sort.
S
Preparing for C++ interview. Have intermediate experience and knowledge about C++. Want to be expert in C++? Anyone please guide and show some path to achieve same.
S
Prepare OOPs concepts
Okey Thank you. Theoretical I guess I have gained somewhat. Do you know any platform to be expert on practical OPPS concepts?
S
Okey , Thank you
Adam
RIP cppcast 😢
Jean
RIP cppcast 😢
it stopped?
Adam
it stopped?
it did, this week
Jean
will it resume some day?
Adam
they said maybe ... rob has a new job not doing c++, so felt it was right time to end
Jean
sad
Adam
yeah, big gap to fill in my commute!
Adam
it was a nice episode/ending
Julius
How to outline algorithm to accept a user name and repeat a welcome message
Anonymous
they said maybe ... rob has a new job not doing c++, so felt it was right time to end
I thought Jason was the one leaving. He said he will continue with C++ Weekly but
Adam
No, it was initiated by rob (thats not meant as a negative) as he felt it was time to take a hiatus as he wasnt doing and c++ (c#) ... jason said he was continuing c++ weekly
Anonymous
No, it was initiated by rob (thats not meant as a negative) as he felt it was time to take a hiatus as he wasnt doing and c++ (c#) ... jason said he was continuing c++ weekly
Oh ok. I didn't catch up on many episodes in the recent past but the ones that I did listen to were awesome. Sad to know that it is ending.
Anshul
in this question i try to use simple recursive approach by traversing all the paths possible, this approach works but gives TLE which is obvious. Then i thought to use DP but then i am getting wrong answer. Can anyone please help out why? Here is the code link: https://pastebin.com/93Hr0Fww Here is the question link: https://leetcode.com/problems/shortest-path-in-binary-matrix/
Anshul
I'm adding 1 to the count received from subcall
Anshul
Let's suppose the base call returned 1 then the call prev to it will return 1+1=2, and further prev calls will return 3 4 5 and so on
Anonymous
Let's suppose the base call returned 1 then the call prev to it will return 1+1=2, and further prev calls will return 3 4 5 and so on
The cnt variable is useless. You always return 1 if the destination node is directly reachable from the node on which the current dp call is being made. So you may as well removethat variable and just return 1. On the first reading of your code,I thought cnt is whereyou will keep track ofthe number of steps and set dp to that value and thought you weren't doing it. It seems fine. I will look into it again
Anonymous
Could you find the issue
Haven't looked into it yet.
Anshul
Okay
r3tr0m
Hi
Anonymous
Hello. Maybe someone can help solve the following problem: Write a function that adds a column to a 2D array by the specified number. I have code that adds a column to the end of the array, here is the code: void AddCol(int**& arr, int row, int& col) { int** temp = new int* [row]; for (int i = 0; i < row; i++) { temp[i] = new int[col + 1];// col = col + 1; } for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { temp[i][j] = arr[i][j]; } } for (int i = 0; i < row; i++) { delete[]arr[i]; } delete[]arr; arr = temp; for (int i = 0; i < row; i++) { arr[i][col] = 7; } col++; } It needs to be adjusted so that the column can be added to the specified number. I will be grateful for any help.
Anonymous
Could you find the issue
The solution seems fine to me on going through it superficially. Try using a debugger to see what the issue is. Your DP equation seems right. Btw you can also initialize those elements of dp where grid[i ][j] == 1 to some value like -1 instead of checking for that using a condition.
Anonymous
Hi, can anyone help me to read a specific line from a file without line number, i mean like with a some word? In c programming
Anonymous
I tried to print dp array but I still can't understand what's wrong
Hmm. Well the problem with your code is that your DP solution actually has a subtle bug. It is because of setting grid[i][j] to -2 to prevent a node from being visited again by further recursive calls. But the problem here is that you forget that the recursion is very deep and there will be multiple nodes that will be marked as -2 (even those that can be visited). You are assuming that you are setting only grid[i][j] to a negative number for the following 8 recursive calls but you forget that there has been a sequence of calls before the current recursive call which would have marked other nodes also as negative (even those that are on the optimal path). So your DP solution would not be able to visit these nodes and hence not find an optimal path. This clarifies that DP is not the right way to solve this problem. You have to use BFS instead.
Nils
Hi, can anyone help me to read a specific line from a file without line number, i mean like with a some word? In c programming
Well, just read the file word for word always storing the offset of the start of the current line until you found the word you wanted
Anton
Hi, if anyone uses RapidJSON library please help - is there a way to get a Pointer pointing to result of FindMember?
ِ
Hi can anyone help me give main idea. How explain the code and converting to flowchart. I have the code
m
Hi everyone, it it possible to use typename inside struct? I have a class that takes 10 inputs so I was thinking about compining them into a struct but 3 of them are customs types that I "typedef" in another file, I tried googling it but I could not get anywhere
Nils
Hey, c char **read_whitelist(const char *whitelist_path) { // Open file FILE *whitelist_file = fopen(whitelist_path, "r"); // Read line for line size_t whitelist_size = sizeof(char**)*2, whitelist_top = 0; char **whitelist = malloc(whitelist_size); while (!feof(whitelist_file)) { char *executable = NULL; size_t executable_len; if (getline(&executable, &executable_len, whitelist_file) >= 0 && executable_len != 0) { executable[executable_len-1] = '\0'; printf("Added to whitelist: <%zu> %s\n", executable_len, executable); if (whitelist_top*sizeof(char**) >= whitelist_size-1) { whitelist_size = (whitelist_top+6)*sizeof(char**); whitelist = realloc(whitelist, whitelist_size); } whitelist[whitelist_top++] = executable; } } // Clean up whitelist[whitelist_top] = NULL; fclose(whitelist_file); return whitelist; } Hey, any idea what might be going on here? Whatever I do, executable_len always ends up being 120...
ِ
using namespace std; int main () { const int NUMGRADES = 4; const int NUMSTUDENTS =20; int i,j; double grade, total,avarge; for (i=1;i<=NUMSTUDENTS; i++) { total =0; for (j=1; j <= NUMGRADES; j++) { cout << "Enter a grade for this stuednt"; cin >> grade; total = total+ grade; } average = total/NUMGRADES; cout << "\n The average for student " << i << "is" << avarage << "\n\n"; } return0; } can anyone help me how explain shortly the code and converted to flowschart ?
Leandro
QUESTION ABOUT BASIC C: let's say I declare a static pointer, initialize it to some dynamically allocated memory inside a function, and then use it as the return value of the function, which in turn is used in my program as the value given to another pointer inside main(). If I use free() with the pointer I created inside main() which holds the value returned from the function as argument, will it successfully deallocate the memory I allocated inside the original function?
Pavel
QUESTION ABOUT BASIC C: let's say I declare a static pointer, initialize it to some dynamically allocated memory inside a function, and then use it as the return value of the function, which in turn is used in my program as the value given to another pointer inside main(). If I use free() with the pointer I created inside main() which holds the value returned from the function as argument, will it successfully deallocate the memory I allocated inside the original function?
You can see a pointer as an address, when you allocate some memory you are getting an address to that memory that you save to the pointer. When you return it as a value, the returned pointer will point to the same memory, so when you free that pointer, that same memory will be freed (and then the pointer that is saved as static variable or any copies of this pointer will become dangling pointers, meaning that they will point to freed memory)
*
Suppose, you call Rotate ByK(a, 1000000000). You will find that your program takes a lot of time. How can you optimize your program? How can i solve this?
klimi
(It's really not that hard)
● Igor
i have this simple code but it is causing segfault when i do s->current = 0; i would like to understand why it is happening so i can study it a little better: #include <stdio.h> typedef struct { int current; } stack; stack* stack_new() { stack *s; s->current = 0; return s; }
● Igor
you haven't initialize s yet:
oh, thx :) my mistake was that i was treating the pointer like if it was a struct that is automatically initialized, example: stack my_stack; my_stack.current = 0; which is different to: stack* my_stack_pointer; my_stack_pointer->current = 0; // segfault
● Igor
Suppose, you call Rotate ByK(a, 1000000000). You will find that your program takes a lot of time. How can you optimize your program? How can i solve this?
modulus operation... think of angles: if you rotate 360º, you will end up at the same position as if you rotate 0º, 720º, and so on
f
hello guys
f
i am trying to learn c++
f
can u suggest me best resoure to learn
Anonymous
Hi,i am also learning c++
f
can we be study partners
Anonymous
I asked some questions about c++ that's some links to learn..
Kosa
#include <iostream> using namespace std; //Operator Overloading class OperatorClass { private: int x, y; public: OperatorClass(int a = 0, int b = 0) { x = a; y = b; } void Print() { cout << "x=" << x << ",y=" << y << endl; } //Unar Operator void operator-() { x = -x; y = -y; } void operator++() { cout << "Pre increment "; ++x; ++y; } void operator++(int a) { cout << "Post increment "; x++; y++; } //Binary Operator OperatorClass operator+(OperatorClass T) { OperatorClass Temp; Temp.x = x + T.x; Temp.y = y + T.y; return Temp; } OperatorClass operator+(int k) { OperatorClass Temp(x+k, y+k); return Temp; } void operator+=(OperatorClass T) { x += T.x; y += T.y; } OperatorClass operator*(OperatorClass T) { OperatorClass Temp(x * T.x, y * T.y); return Temp; } OperatorClass operator-(OperatorClass T) { OperatorClass Temp(x - T.x, y - T.y); return Temp; } bool operator>(OperatorClass T) { if (x > T.x && y > T.y) return true; else return false; } bool operator==(OperatorClass T) { return (x == T.x && y == T.y); } int operator[](int i) { if (i == 0) return x; else if (i == 1) return y; else return 0; } };
Kosa
Write main this code
smene
Hi, how can I build modern windows desktop applications?
三体183号
mfc
Anonymous
Archive function overloading in c++
Anonymous
Ehsan
I have a problem with arrays: double tfVectors[status.numDocuments][argc - 1]; double idfVectors[argc - 1]; calculate_TF_IDF(argc-1, idfVectors, tfVectors, &status, argv, documents); I pass tfVectors to calculate_TF_IDF but when it finishes there is inconsistency with its values I have put this statement in main and calculate-TF_IDF: printf("%lf, %lf, %lf", tfVectors[1][0], tfVectors[1][1], tfVectors[1][2]); and they give different results !! calculate_TF_IDF: 0.000000, 0.333333, 0.333333 main: 0.333333, 0.333333, 0.000000
Anonymous
Ok, forgot all that.....
Anonymous
How to make function overloading in c++(simple code)?
神 ꜰʟᴀꜰꜰʏ
Organize a stack to store integers. For the stack, use the unsigned short array. Demonstrate adding an element, removing an element, adding to an overflowing stack, removing from an empty stack. After each example, output the contents of the stack.
神 ꜰʟᴀꜰꜰʏ
can someone help?
Beyond
c++
Beyond
😀
神 ꜰʟᴀꜰꜰʏ
сpp
神 ꜰʟᴀꜰꜰʏ
thanks, but I've already written using copilot lmao