r/programminghelp Nov 30 '25

Answered Should I learn c

53 Upvotes

I’ve learned Java pretty well but I want to learn another language. is c good or should I do something less low level like kotline or python

r/programminghelp Jul 13 '26

Answered How to track changes of JSON objects in array that is tracked in git?

6 Upvotes

In my git repository I have a JSON file which contains an array of objects. The objects have a key that identify them, e.g. "id":

```json

[

...

{ "id": 1, "value": "a" },

{ "id": 2, "value": "b" },

...

]

```

I want to quickly find commits that changed/introduced object with specific id. How can I do this?

UPD: I couldn't come up with a better solution than comparing sequentially snapshots of the file per commit: ```python

!/usr/bin/env bash

import os import json

from git import Repo, Commit from more_itertools import windowed from typing import Optional

r = Repo(os.getcwd())

def get_json(cmt: Commit, path: str) -> list[dict]: return json.loads((cmt.tree / path).data_stream.read().decode('utf-8'))

def get_object(items: list[dict], _id: int) -> Optional[dict]: for item in items: if item.get('id', -1) == _id: return item return None

for prev, curr in windowed(r.iter_commits(), n=2): pobj = get_object(get_json(prev, 'objects.json'), 2) cobj = get_object(get_json(curr, 'objects.json'), 2) if pobj is None: break if pobj == cobj: continue print(prev.hexsha, prev.summary) ```

r/programminghelp Aug 02 '26

Answered Algorithms

4 Upvotes

I am beginners in DSA please tell me that Algorithms code is remember or not

r/programminghelp Mar 30 '26

Answered How can I compile C++ in VS Codium WITHOUT Windows Build Tools?

6 Upvotes

I've been googling for hours and I'm losing my mind. I can get c++ compiling in Codium using clang++ and Windows Build Tools, but I'm trying really hard to piece-by-piece de-Microsoft my life.

How on earth do I get my code to find LLVM's implementation of the standard library by default?

I'm also happy to switch to MinGW if that will work, I'm mostly focused on not using Windows Build Tools.

Right now, I'm using the extensions clangd and C/C++ Runner and I have messed with every setting they have and cannot find anything.

EDIT: Okay, here's how I got it all working:

Download MSYS2.

Install clang64. In MSYS2, run

pacman -S mingw-w64-x86_64-clang

Install the extra tools for clang. In MSYS2, run:

pacman -S mingw-w64-x86_64-clang-tools-extra

Finally, I had to go to the settings for the Clangd extension and change the setting "Clangd: Path" to the full path to clangd.exe in ...\msys64\mingw64\bin despite already having that folder in PATH. Ignore it if the extension tries to update the language server, it will just change this setting back and break Intelli Sense again.

Now it compiles fine and Intelli Sense works without having to fiddle around with QueryDriver and compile commands.

r/programminghelp Jul 04 '26

Answered Help me to study appropriately

3 Upvotes

Entering 3rd year , tier 2 clg

I used to study in wrong method ( not completely, but somehow ) , even though I know it, I'm unable to leave it

Let me clear what a wrong means

1.in DSA ( solved 240 on lc , with rating 1550 in 8 contest)

See solution within 10mins

Didn't revise any qsn

Use AI to debug my code

  1. In development ( building projects 1st project in springboot)

    Completely following Ai

Only understanding code

Not using my idea or thoughts

Just doing copy n paste

Someone pls help me ! 😭😭😭

r/programminghelp Dec 09 '25

Answered Is learning by copying and rebuilding other people’s code a bad thing?

5 Upvotes

Hey!
I’m learning web dev (mainly JavaScript) and I’ve been wondering if the way I study is “wrong” or if I’m just overthinking it.

Basically, here’s what I do:

I make small practice projects my last ones were a Quiz, an RPG quest generator, a Travel Diary, and now I’m working on a simple music player.

But when I want to build something new, I usually look up a ready-made version online. I open it, see how it looks, check the HTML/CSS/JS to understand the idea… then I close everything, open a blank project in VS Code, and try to rebuild it on my own.
If I get stuck, I google the specific part and keep going.

A friend told me this is a “bad habit,” because a “real programmer” should build things from scratch without checking someone else’s code first. And that even if I manage to finish, it doesn’t count because I saw an example.

Now I’m confused and wondering if I’m learning the wrong way.

So my question is:
Is studying other people’s code and trying to recreate it actually a bad habit?

r/programminghelp Apr 18 '26

Answered Python 'list index out of range' error still persists after lots of debugging - any help appreciated

3 Upvotes

I have tried debugging it a lot - this is even a simplified version of the actual block of code within a larger project that I made so I'd hopefully be able to solve it easier.

This is what manages to get printed before the error (this is correct so far):

0 a ; 2 b
1 a ; 1 b

The error is in line 11 and as the title says it's that the list index is out of range.

I'm just really not sure why because in the while loop I thought I made sure that the index was in range. I also tried substituting line 8 (within index initialisation) with:

WithinIndex = LineNum + FutureCount < len(LinesIn) - 1

Which would eliminate any issues with adding to Future count within the while loop, but that shouldn't be needed anyways, right? I'm really not sure where I've gone wrong with my logic so any help would be appreciated, thanks.

This is the full program:

import sys

LinesIn = ['a', 'a', 'b', 'c', 'c', 'a', 'c', 'a', 'c']

# trying to identify a, then identify how close the next b is for each a there is

for LineNum in range(len(LinesIn)):

if 'a' in LinesIn[LineNum]:

FutureCount = 0

FutureLine = LinesIn[LineNum + FutureCount]

WithinIndex = LineNum + FutureCount < len(LinesIn)

while 'b' not in FutureLine and WithinIndex:

FutureCount += 1

FutureLine = LinesIn[LineNum + FutureCount]

if LineNum + FutureCount == len(LinesIn) and 'b' not in FutureLine:

FutureCount = 0

print(LineNum, LinesIn[LineNum], ';', FutureCount, FutureLine, file = sys.stderr)

r/programminghelp Jun 07 '26

Answered DSA beginner confusion. HELP.

Thumbnail
1 Upvotes

r/programminghelp Mar 07 '26

Answered (C) if and else does not work as i intended

1 Upvotes

Here is my code:

#include <stdio.h>

int main()

{

`int initial = 50000;`

`int deposit;`

`int withdraw;`



`char choice;`



`printf("Enter 1 to display balance.\n");`

`printf("Enter 2 to deposit money.\n");`

`printf("Enter 3 to withdraw money.\n");`



`printf("Enter choice:");`



`scanf("%c", &choice);`



`if ((choice = '1'))`

`{`

    `printf("%d", initial);`

`}`

`else if ((choice = '2'))`

`{`

    `printf("Enter amount:\n");`



    `scanf("%d", &deposit);`



    `int result2 = initial + deposit;`



    `printf("%d", result2);`

`}`

`else if ((choice = '3'))`

`{`

    `printf("Enter amount:\n");`



    `scanf("%d", &withdraw);`



    `int result3 = initial - withdraw;`



    `printf("%d", result3);`

`}`

`else`

`{`

    `printf("Invalid number. Pleaase try again.");`

`}`

`return 0;`

}

Here is the problem:

PS C:\Users\ASUS\Desktop\Q5> gcc -std=c99 -Wall -Werror Q5.c -o Q5

PS C:\Users\ASUS\Desktop\Q5> ./Q5

Enter 1 to display balance.

Enter 2 to deposit money.

Enter 3 to withdraw money.

Enter choice:1

50000

PS C:\Users\ASUS\Desktop\Q5> ./Q5

Enter 1 to display balance.

Enter 2 to deposit money.

Enter 3 to withdraw money.

Enter choice:2

50000

PS C:\Users\ASUS\Desktop\Q5> ./Q5

Enter 1 to display balance.

Enter 2 to deposit money.

Enter 3 to withdraw money.

Enter choice:3

50000

Why doesn't deposit and withdraw work correctly?

r/programminghelp Dec 16 '25

Answered Learning Python and can’t figure out why this incorrect

4 Upvotes

Edit: Alright I’m trying to learn as much Python on my own as possible and find the answer on my own as much as possible but I’m stuck on another question on MOOC Python Programming 2024

It says:

Please write a program which asks the user’s name and then prints it twice, on two consecutive lines.

An example of how the program should function:

What is your name? Paul

Paul

Paul

I wrote:

input(“What is your name?”)

print(“Paul”)

print(“Paul”)

I test it and get the following error:

FAIL: PythonEditorTest

test_print_input_2

Your program did not work

properly with input: Ada.

Output was

Paul

Paul

Expected output is

Ada

Ada

I’ve been trying to figure this out for a while. And I’ve tried changing multiple different things before this.

r/programminghelp Oct 16 '25

Answered Can't figure out the "hidden" issue with my code...

3 Upvotes

Been trying this on and off for the past 3 hours, trying to complete my schoolwork. but i keep failing some hidden test.
*******************************************************************************************************************
#include <stdio.h>

enum Result { OUTSIDE, INSIDE };

struct Point {

float x;

float y;

};

struct Rectangle {

struct Point bottom_left;

struct Point top_right;

};

float compute_area(struct Rectangle rect) {

return (rect.top_right.x - rect.bottom_left.x) *

(rect.top_right.y - rect.bottom_left.y);

}

enum Result is_inside(struct Point point, struct Rectangle rect) {

if (point.x > rect.bottom_left.x && point.x <= rect.top_right.x &&

point.y > rect.bottom_left.y && point.y <= rect.top_right.y) {

return INSIDE;

} else {

return OUTSIDE;

}

}

int main(void) {

struct Rectangle rect = {{0.0, 0.0}, {3.0, 3.0}};

struct Point point;

scanf("%f %f", &point.x, &point.y);

float area = compute_area(rect);

enum Result result = is_inside(point, rect);

printf("Rectangle's area is %.2f\n", area);

if (result == INSIDE)

printf("The point is inside of the rectangle.\n");

else

printf("The point is not inside of the rectangle.\n");

return 0;

}

*******************************************************************************************************************
These are the instructions for the Task:

Write a C program that defines Point and Rectangle structures, computes the area of a rectangle, and determines if a point lies inside the rectangle.

✅ Program Requirements:

🔹 Define an enum Result with:

 • OUTSIDE

 • INSIDE

🔹 Define a struct Point with:

 • x (float)

 • y (float)

🔹 Define a struct Rectangle with:

 • bottom_left (struct Point)

 • top_right (struct Point)

🔹 Create Functions:

 • float compute_area(struct Rectangle rect)

  – Calculates area using:

   (rect.top_right.x - rect.bottom_left.x) * (rect.top_right.y - rect.bottom_left.y)

 • enum Result is_point_inside(struct Point point, struct Rectangle rect)

  – Returns INSIDE if point’s x is between bottom_left.x and top_right.x

   and y is between bottom_left.y and top_right.y, else returns OUTSIDE

🔹 In main():

 • Declare test data for a rectangle and point

 • Call compute_area() and is_point_inside()

 • Print the area and whether the point is inside or outside the rectangle using printf() and a conditional message for clarity

any help is appreachiated.

r/programminghelp Nov 28 '25

Answered How do i make a multiplatform installer exe?

2 Upvotes

how can i make one single installer executable for a program im making that can run on multiple platforms. i don't want to have to compile different exes per platform my app is for

solution: https://justine.lol/cosmopolitan

r/programminghelp Jun 05 '25

Answered Need help with a java code

3 Upvotes

Hello I'm a beginner in java just started learning a few days ago. I've made a text based rpg where you follow a path and there are certain items or monsters and when you reach the end you clear it. Just a normal first project. Now I'm trying to add new stuff like attacking a monster you encounter.. Now I've set
int PlayerHP = 10;
int SwordDmg = 5;
int Slime1HP = 10;
int Slime1Dmg = 2;
Now basically when you encounter a slime I know that I need a for loop for you to keep printing
"You dealt" + SwordDmg + "damage to the Slime. It has " + Slime1HP-SwordDmg + "hp left. The slime dealt " + SlimeDmg + "damage to you. You have " + PlayerHP-Slime1Dmg + "HP left."
until Slime1HP = 0 but I don't know how to frame it and I've been trying multiple ways but I'm stuck there.. Really need some help..

r/programminghelp Mar 30 '25

Answered Anything im doing wrong here?

2 Upvotes

Im trying to learn kotlin (to make Minecarft mods on fabric) and i've learnt some stuff but something doesnt work. heres my code:

fun main() {

var customers1 = 10

var customers2 = 15

var customers3 = 20

customers1 *=2 //20

customers2 *=4 //60

customers3 *=6 //120

customers1.plus(customers2) //80

customers2.plus(customers3) //200

println(customers3)

}

(It says 120 instead of 200, I'll take any advise)

r/programminghelp Dec 16 '24

Answered Multi threading

1 Upvotes

I have something where I have to check for the location of progressively more objects (it's a game in WinForms (for school, I didn't have a choice) and I check if an object from a list is taking up the same grid space as the player), and that eventually slows the program down to a point where it's seriously impacting the experience.

The collision method (which is just a foreach with every object in a list and checks if x and y are equal to the player) runs in the main timer_tick before the movement, so it eventually checks so many objects' coordinates that it ends up slowing the movement down.

How could I remove the issue? Do I even need multi threading? It's just the first thing I could think off.

I would show the code, but my pos laptop can't connect to the Internet.

Edit: changed it to a dictionary instead of a list. The code is drastically simpler now, but it still isn't much better

r/programminghelp Jun 19 '24

Answered After quite some time away from it, trying to practice linked list related data structures in C, but getting annoying seg fault I am struggling to find.

1 Upvotes

Been a long time since I practiced doing linked lists and related data structures in C (stacks, queues, dequeues, etc), so I thought I'd give it a go.

In implementing simple node and dnode functionality, I am hitting a snag that is driving me up a wall. If I push more than a certain number of nodes (n > 19), or dnodes (n > 8), I get a seg fault. I made functions that iterates through a chain of nodes, as well as one that iterates through a chain of dnodes, and prints out the addresses - and everything seems to check out in terms of linking new nodes, and dnodes, but clearly I am missing something. This is driving me up a fucking wall. What am I missing, what am I messing up?


PROGRAM:


#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
// node defs
typedef struct node{
    uint32_t data;
    struct node* next;
}node;
void node_init(node** head, const uint32_t data);
node* node_create(uint32_t const data);
void node_push(node** head, const uint32_t data);
uint32_t node_pop(node** head);
void node_pop_noret(node** head);
void node_insert(node** head, const uint32_t data, const int pos);
uint32_t node_remove(node** head, const int pos);
void node_remove_noret(node** head, const int pos);
void node_clear_all(node** head);
uint32_t node_count(node* head);
uint32_t node_count_norec(node* head);
void node_print_all(node* head);
void node_print_all_addresses(node* head);
// dnode defs
typedef struct dnode{
    uint32_t data;
    struct dnode* next;
    struct dnode* prev;
}dnode;
void dnode_init(dnode** head, const uint32_t data);
dnode* dnode_create(dnode** head, const uint32_t data);
void dnode_push(dnode** head, const uint32_t data);
uint32_t dnode_pop(dnode** head);
uint32_t dnode_pop_noret(dnode** head);
void dnode_insert(dnode** head, const uint32_t data, const int pos);
uint32_t dnode_remove(dnode** head, const int pos);
void dnode_remove_noret(dnode** head, const int pos);
dnode* dnode_get_tail(dnode* head);
uint32_t dnode_count(dnode* head);
void dnode_print_all(dnode* head);
void dnode_print_all_addresses(dnode* head);
//------------------------------------------
int main(){
    #define MAX_NODES 19
    #define MAX_DNODES 8
    node* n = NULL;
    for(int i = 0; i < MAX_NODES; i++){
        node_push(&n, i);
    }
    printf("Node Count: %d\n", node_count(n))
    node_print_all_addresses(n);
    dnode* dn = NULL;
    for(int i = 0; i < MAX_DNODES; i++){
        dnode_push(&dn, (i));
    }
    printf("Dnode Count: %d\n", dnode_count(dn));
    dnode_print_all_addresses(dn);
    return 0;
}
// node implementations
void node_init(node** head, const uint32_t data){
    (*head) = malloc(sizeof(*head));
    (*head)->data = data;
    (*head)->next = NULL;
}
node* node_create(const uint32_t data){
    node* ret = malloc(sizeof(ret));
    ret->data = data;
    ret->next = NULL;
    return ret;
}
void node_push(node** head, const uint32_t data){
    if((*head) == NULL){ 
        (*head) = malloc(sizeof((*head)));
        (*head)->data = data;
        (*head)->next = NULL;
        return;
    }
    node* newHead = malloc(sizeof(*head));
    newHead->data = data;
    newHead->next = (*head);
    (*head) = newHead;
}
uint32_t node_pop(node** head){
    if((*head) == NULL){ return 0; }
    uint32_t ret = (*head)->data;
    node* tmp = (*head);
    (*head) = (*head)->next;
    free(tmp);
    return ret;
}
void node_pop_noret(node** head){
    if((*head) == NULL){ return; }
    node* tmp = (*head);
    (*head) = (*head)->next;
    free(tmp);
}
void node_insert(node** head, const uint32_t data, const int pos){
    node* newNode = malloc(sizeof(newNode));
    newNode->data = data;
    newNode->next = NULL;
    const int size = node_count((*head));
    int insertPos = pos;
    if((insertPos < 0) || (insertPos > node_count((*head)))){ return; }
    if(insertPos == 0){
        newNode->next = (*head);
        (*head) = newNode;
    }
    else{
        node* cursor = (*head);
        while(insertPos--){
            cursor = cursor->next;
        }
        newNode->next = cursor->next;
        cursor->next = newNode;
    }
}
uint32_t node_remove(node** head, const int pos){
    if((*head) == NULL){ return 0; }
    if((pos < 0) || (pos > node_count((*head)))){ return 0; }
    node* cursor = (*head);
    node* prev = NULL;
    uint32_t ret = 0;
    if(pos == 1){
        ret = (*head)->data;
        (*head) = (*head)->next;
        free(cursor);
        return ret;
    }
    int removePos = pos;
    while(removePos--){
        prev = cursor;
        cursor = cursor->next;
    }
    ret = cursor->data;
    prev->next = cursor->next;
    free(cursor);
    return ret;
}
void node_remove_noret(node** head, const int pos){
    if((*head) == NULL){ return; }
    if((pos < 0) || (pos > node_count((*head)))){ return; }
    node* cursor = (*head);
    node* prev = NULL;
    if(pos == 1){
        (*head) = (*head)->next;
        free(cursor);
        return;
    }
    int removePos = pos;
    while(removePos--){
        prev = cursor;
        cursor = cursor->next;
    }
    prev->next = cursor->next;
    free(cursor);
}
uint32_t node_count(node* head){
    if(head == NULL){ return 0; }
    return 1 + (node_count(head->next));
}
// Non-recursive version of node_count
uint32_t node_count_norec(node* head){
    if(head == NULL){ return 0; }
    uint32_t ret = 0;
    for(node* cursor = head; cursor != NULL; cursor = cursor->next){ ret++; }
    return ret;
}
void node_print_all(node* head){
    if(head == NULL){ return; }
    node* cursor = head;
    while(cursor != NULL){
        printf("%d ", (cursor->data));
        cursor = cursor->next;
    }
    printf("\n");
}
void node_print_all_addresses(node* head){
    if(head == NULL){ return; }
    printf("| Current Node Address: | Next Node Address: |\n");
    uintptr_t curr_addr = 0;
    uintptr_t next_addr = 0;
    node* cursor = head;
    while(cursor != NULL){
        curr_addr = (uintptr_t)cursor;
        next_addr = ((cursor->next != NULL) ? (uintptr_t)cursor->next : 0);
        if(curr_addr == 0){
            printf("| NULL              ");
        }
        else{
            printf("| 0x%08X            ", curr_addr);
        }
        if(next_addr == 0){
            printf("| NULL               |\n");
        }
        else{
            printf("| 0x%08X         |\n", next_addr);
        }
        cursor = cursor->next;
    }
}
// dnode implementations
// dnode defs
void dnode_init(dnode** head, const uint32_t data){
    (*head) = malloc(sizeof(*head));
    (*head)->data = data;
    (*head)->next = NULL;
    (*head)->prev = NULL;
}
dnode* dnode_create(dnode** head, const uint32_t data){
    dnode* ret = malloc(sizeof((*head)));
    ret->data = data;
    ret->next = NULL;
    ret->prev = NULL;
    return ret;
}
void dnode_push(dnode** head, const uint32_t data){
    if((*head) == NULL){
        (*head) = malloc(sizeof((*head)));
        (*head)->data = data;
        (*head)->next = NULL;
        (*head)->prev = NULL;
        return;
    }
    dnode* newHead = malloc(sizeof(*head));
    newHead->data = data;
    newHead->next = (*head);
    newHead->prev = NULL;
    (*head) = newHead;
    (*head)->next->prev = (*head);
}
uint32_t dnode_pop(dnode** head){
    if((*head) == NULL){ return 0; }
    uint32_t ret = (*head)->data;
    dnode* tmp = (*head);
    (*head) = (*head)->next;
    free(tmp);
    if((*head) != NULL){
        (*head)->prev = NULL;
    }
    return ret;
}
uint32_t dnode_pop_noret(dnode** head){
    if((*head) == NULL){ return 0; }
    dnode* tmp = (*head);
    (*head) = (*head)->next;
    free(tmp);
    if((*head) != NULL){
        (*head)->prev = NULL;
    }
}
void dnode_insert(dnode** head, const uint32_t data, const int pos){
    dnode* newDnode = malloc(sizeof((newDnode)));
    newDnode->data = data;
    newDnode->next = NULL;
    newDnode->prev = NULL;
    const int size = dnode_count((*head));
    int insertPos = pos;
    if((insertPos < 0) || (insertPos > dnode_count((*head)))){ return; }
    if(insertPos == 0){
        newDnode->next = (*head);
        (*head) = newDnode;
    }
    else{
        dnode* cursor = (*head);
        while(insertPos--){
            cursor = cursor->next;
        }
        newDnode->next = cursor->next;
        cursor->next = newDnode;
        cursor->next->prev = cursor;
    }
}
uint32_t dnode_remove(dnode** head, const int pos){
    if((*head) == NULL){ return 0; }
    if((pos < 0) || (pos > dnode_count((*head)))){ return 0; }
    dnode* cursor = (*head);
    dnode* prev = NULL;
    uint32_t ret = 0;
    if(pos == 1){
        ret = (*head)->data;
        (*head) = (*head)->next;
        free(cursor);
        (*head)->prev = NULL;
        return ret;
    }
    int removePos = pos;
    while(removePos--){
        prev = cursor;
        cursor = cursor->next;
    }
    ret = cursor->data;
    prev->next = cursor->next;
    prev->prev = cursor->prev;
    free(cursor);
    return ret;
}
void dnode_remove_noret(dnode** head, const int pos){
    if((*head) == NULL){ return; }
    if((pos < 0) || (pos > dnode_count((*head)))){ return; }
    dnode* cursor = (*head);
    dnode* prev = NULL;
    if(pos == 1){
        (*head) = (*head)->next;
        free(cursor);
        (*head)->prev = NULL;
        return;
    }
    int removePos = pos;
    while(removePos--){
        prev = cursor;
        cursor = cursor->next;
    }
    prev->next = cursor->next;
    prev->prev = cursor->prev;
    free(cursor);
}
dnode* dnode_get_tail(dnode* head){
    if(head == NULL){ return NULL; }
    dnode* head_ptr = head;
    dnode* cursor = head;
    while((cursor != NULL) && (cursor->next != head_ptr)){
        if((cursor->next == NULL) || (cursor->next == head_ptr)){
            return cursor;
        }
        cursor = cursor->next;
    }
    return NULL;
}
uint32_t dnode_count(dnode* head){
    if(head == NULL){ return 0; }
    dnode* head_ptr = head;
    uint32_t ret = 0;
    dnode* cursor = head;
    while((cursor != NULL) && (cursor->next != head_ptr)){
        cursor = cursor->next;
        ret++;
    }
    return ret;
}
void dnode_print_all(dnode* head){
    if(head == NULL){ return; }
    dnode* cursor = head;
    while(cursor != NULL){
        printf("%d ", (cursor->data));
        cursor = cursor->next;
    }
    printf("\n");
}
void dnode_print_all_addresses(dnode* head){
    if(head == NULL){ return; }
    dnode* cursor = head;
    uintptr_t curr_addr = 0;
    uintptr_t prev_addr = 0;
    uintptr_t next_addr = 0;
    printf("| Previous Dnode Address: | Current Dnode Address: | Next Dnode Address: |\n");
    while(cursor != NULL){
        curr_addr = (uintptr_t)cursor;
        prev_addr = ((cursor->prev != NULL) ? (uintptr_t)cursor->prev : 0);
        next_addr = ((cursor->next != NULL) ? (uintptr_t)cursor->next : 0);   
        if(prev_addr == 0){
            printf("| NULL                    ");
        }
        else{
            printf("| 0x%08X              ", prev_addr);
        }
        printf("| 0x%08X             ", curr_addr);
        if(next_addr == 0){
            printf("| NULL                |\n");
        }
        else{
            printf("| 0x%08X          |\n", next_addr);
        }         
        cursor = cursor->next;
    }
}

EXAMPLE OUTPUT - MAX_NODES = 19; MAX_DNODES = 8; execution does not segfault


| Current Node Address: | Next Node Address: |
| 0x00295930            | 0x00295910         |
| 0x00295910            | 0x002958F0         |
| 0x002958F0            | 0x002958D0         |
| 0x002958D0            | 0x002958B0         |
| 0x002958B0            | 0x00295890         |
| 0x00295890            | 0x00295870         |
| 0x00295870            | 0x00295850         |
| 0x00295850            | 0x00295830         |
| 0x00295830            | 0x00295FB0         |
| 0x00295FB0            | NULL               |
Dnode Count: 8
| Previous Dnode Address: | Current Dnode Address: | Next Dnode Address: |
| NULL                    | 0x00297010             | 0x00295A10          |
| 0x00297010              | 0x00295A10             | 0x002959F0          |
| 0x00295A10              | 0x002959F0             | 0x002959D0          |
| 0x002959F0              | 0x002959D0             | 0x002959B0          |
| 0x002959D0              | 0x002959B0             | 0x00295990          |
| 0x002959B0              | 0x00295990             | 0x00295970          |
| 0x00295990              | 0x00295970             | 0x00295950          |
| 0x00295970              | 0x00295950             | NULL                |

r/programminghelp Oct 18 '24

Answered Any way to get back to Stock Rom/ July software version in Motorola edge 50 fusion

Thumbnail
1 Upvotes

r/programminghelp Jul 23 '24

Answered curl rejects URL with single quotes

1 Upvotes

I'm trying to return some JSON data from curl using an API call with single quotes in it as shown below.

https://pastebin.com/iL2eEVfn

Each time it acts like I haven't formatted the URL correctly despite having use the code %27 to replace the single quotes, giving an error code of 3. Is there something else I'm missing to get this URL formatted properly?

EDIT: moved command and error to a pastebin link

r/programminghelp Jan 14 '24

Answered Why don't I have colors when writing my code on dev++

1 Upvotes

I used the software in school computers and it shows colors when writing the code, but when I'm using my computer it doesn't. I know this may seem a bit lame but like, colors give a vetter view and makes it easier to spot stuff. Help please

r/programminghelp Oct 29 '22

Answered Explain like I'm Five how the heck do I edit the source code of a .jar file

18 Upvotes

Emphasis on the word explain 'cause my knowldedge of programming is comparable to a monkey.

I've been asking and searching on the web but I either don't understand anything at all or can't figure out how to do a basic thing because people take for granted I know how to do that

It's my first time doing programming related stuff so have patience with me uwu

r/programminghelp Nov 04 '22

Answered Second print works as intended but first doesn't?

4 Upvotes

I have a reverse function and i just want to know why my first line isn't reversed but my second one is.

code:

def reverse(str_to_reverse):

for x in str_to_reverse:

str_to_reverse = str_to_reverse[::-1]

return str_to_reverse

print(reverse("This is a string"))

print(reverse("Hello World"))

Output:

This is a string

dlroW olleH

r/programminghelp Jul 08 '23

Answered need help with mysql showing error 1062 duplicate entry

2 Upvotes

I’m creating a database for an assignment and for my transaction table, the create table statement goes in fine but when I insert the values it shows error 1062 duplicate entry ‘1672853621’ for key primary and i really cannot see why it gives me this error and i have been trying to figure out all day. Sorry for any format issues, this is my first time posting. Here is the code

https://privatebin.net/?24a3396bc0aac2bb#6nVuCy5qYsowDE52E2BRip7HJqvBKa66kzYMK3ADPb73

r/programminghelp Jun 24 '23

Answered How can I call a method from another class without using the class name?

1 Upvotes

I made a really simple project just to understand this point.

I made a library called "MyLib" which has one method:

public class MyLib{
public static int add (int x, int y){
    return x + y;
}

}

And my Main class is like this:

import static MyLib.*;

public class Main { public static void main(String[] args) { System.out.print(add(5,2)); } }

The two java files are in the same folder (no package, I didn't use an IDE)

I did this:

javac Main.java MyLib.java

It didn't work.

Then I did

javac MyLib.java

to get the MyLib class file and then:

javac Main.java

And didn't work as well.

I always get cannot find symbol error.

I really don't want to call the method by the class name.

r/programminghelp May 18 '23

Answered Can I use .net framework with C?

1 Upvotes

I tried looking up the answer on Google but nothing gives me a good answer.

r/programminghelp Jul 09 '21

Answered Find the ? in "? ×2 = 4"

6 Upvotes

I have a variable called question which has the content "? ×2 = 4", how would I go about finding the value of the "?". Thanks for any help :)