Ramil
Anonymous
In terms of development efficiency, C++ is relatively backward
touhou
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
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.
ABCD
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?
ABCD
ABCD
S
Okey , Thank you
Adam
RIP cppcast 😢
Jean
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
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
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/
Anonymous
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
Anshul
Anshul
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.
Anshul
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.
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
Leandro
*
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
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;
}
Ster-Devs
● 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
Ster-Devs
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..
Anonymous
Kosa
Write main this code
smene
Hi, how can I build modern windows desktop applications?
三体183号
mfc
Anonymous
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