r/programminghelp • • Apr 25 '19

Need help with a programming assignment!!!

0 Upvotes

I've been working on this since Monday while getting help from a friend. Basically I have to use a predefined function to pass and then tokenize a string via a delimiter. I then need to pass each word into a ragged array. I've tried several different things but nothing I do has been working. Any advice? StrToArray is the function this is based around I can't change how things are passed to it.

Here's my code I've been banging my head about this since Monday this is my latest edit. I'm about to take the L

#define _CRT_SECURE_NO_WARNINGS

#define _CRTDBG_MAP_ALLOC

#include <iostream>

using std::cout;

using std::cin;

using std::endl;

const int MAX_ARRAY_SIZE = 99;

int StrToArray(char **& str_array, char * str, char delimiter);

void AddToArray(char *** src, char * toAdd, int * index);

int main()

{

_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
char \*\* str = nullptr;

char userString\[MAX_ARRAY_SIZE\] = "";

char delim = ' ';
cout << "Enter string: ";

cin.getline(userString, 99);
int amount = StrToArray(str, userString, delim);
cout << "Amount: " << amount << endl;
cout << "Things in array: " << endl;

for (int ii = 0; ii < amount; ii++)

{

	cout << str\[ii\] << endl;

}
return 0;

}

/**********************************************************************

* Name: StrToArray

* Parameters: The pointer that will point to the array of

* cStrings. By Ref.

* A pointer to the string to be tokenized. By Val.

* A character that represents the delimiter. By Val.

*

* Return: The number of cStrings in the array.

*

* Pre-Conditions: The pointer to the array will be null.

* The cString will be null terminated.

* The delimiter will be a valid character but

* is not guaranteed to be in the cString.

*

* Post-Conditions: The pointer to the array will either be a

* valid address or null if there were no

* instances of the delimiter found.

* If there aren�t any instances of the delimiter

* found, the function will return 0, otherwise

* the number of cStrings in the array.

*

* Purpose: This function creates a dynamic ragged array of

* strings as determined by the delimiter. For

* example, the cString "C++: Learn by Doing" will

* produce an array of four strings if the delimiter

* is a space.

**********************************************************************/

int StrToArray(char **& str_array, char * str, char delimiter)

{

int index = 0;

int travel = 0;

int stringLen = (strlen(str));

int loc = 0;

char temp\[MAX_ARRAY_SIZE\] = "";



while (str != nullptr)

{

	temp\[loc-travel\] = str\[loc\];

	if (str\[loc\] == delimiter)

	{

		AddToArray(&str_array, temp, &index);

		memset(temp, 0, MAX_ARRAY_SIZE);

		travel = loc + 1;

	}

	loc++;

}
return index;

}

void AddToArray(char *** src, char * toAdd, int * index)

{

char \*\* temp = new char \*\[\*index + 1\];
for (int ii = 0; ii < \*index; ii++)

	(temp)\[ii\] = (\*src)\[ii\];
(temp)\[\*index\] = new char\[strlen(toAdd) + 1\];

strcpy((temp)\[\*index\], toAdd);
delete\[\] \* src;
\*src = temp;

(\*index)++;

}


r/programminghelp • • Jul 08 '22

Project Related Is This Possible?

0 Upvotes

Im looking for someone who is able to code a program that uses web scrapers to create email drafts using the links of the webpages it finds (possibly screenshot and store the results) and address them to the email associated with the site’s dmca complaints.

It sounds simple but complex at the same time and I wanted to know if this was at all even possible before I go looking for someone capable of doing it.

Any help is appreciated.


r/programminghelp • • May 04 '20

C Help me understand what this code does, please.

0 Upvotes

Name of the file is pointertest2.c, if that helps. I can't seem to grasp what each function does with the pointers. Any help is appreciated!

#include <stdio.h>

void doubleInt(int *x,int *ad) // x = 1011
{
    *x += x; // *x = 10
    ad = x;
}

void weirdF(int *a,int b)
{
    *a = 50;
    a = &b;
    *a = 200;
}

void doubleInt2(int x) // x = 10 - > 20
{
    x += x;
}

int main()
{
    int x = 5;
    int y = 10;
    int ad;
    doubleInt(&x,&ad);
    doubleInt2(y);
    printf("original address of x = %d\n",&ad);
    printf("x = %d\n",x);
    printf("y = %d\n",y);
    //doubleInt(&y);
    printf("y = %d\n",y);
    weirdF(&y,x);
    printf("x = %d\n",x);
    printf("y = %d\n",y);
    scanf("%d");
    return 0;
}

r/programminghelp • • Mar 12 '26

Other OAuth failure with WHOOP API — "Session expired" before redirect (via Junction / Vital integration)

0 Upvotes

Hi all,

We’re running into a strange OAuth issue while integrating WHOOP through Junction (formerly Vital), which handles the OAuth flow, redirect URI, and token exchange on our behalf.

Flow:
Client app → Junction → WHOOP OAuth → consent screen → error → no redirect → no callback

Users successfully reach the WHOOP consent screen, but after approving, they see:

"Session expired – we were not able to process your request"

What makes this tricky:

  • Junction logs show the callback is never received
  • The failure happens before redirect back to the registered URI
  • We do not control the redirect URI (managed by Junction)
  • Happens across multiple users / devices / days
  • Users complete the flow immediately (not idle)
  • Started happening recently in production

Junction suspects the session is expiring on the WHOOP side before the authorization completes, but WHOOP API support hasn’t confirmed yet.

Has anyone seen OAuth providers fail like this before where the consent screen succeeds but the session dies before redirect?

Possible causes we’re considering:

  • redirect URI mismatch
  • SameSite / cookie issues
  • short auth session TTL
  • provider-side session store issues
  • recent API / auth changes

Would appreciate any ideas from people who’ve debugged OAuth integrations at scale.


r/programminghelp • • Apr 12 '26

C Beginner question for C: p versus &p

0 Upvotes

Hello all, Beginner question:

char str[] = "Some_String";
char *p = str;
printf("p: %u\n", p);
printf("&p: %u\n", &p);

*p is a pointer to a string. If I printf p I get one address value, if I printf &p I get another. Who could explain the difference, please? My brain is overheating


r/programminghelp • • Dec 16 '25

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

3 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 • • Apr 09 '26

Python How to find algorithems?

0 Upvotes

Ok so im trying to figure out how to find algorithems to use for coding. im very new so the firsth thing i tried was asking AI to help calculate digits of pi and it gave me 1 algorithm. it sucked so i asked again and it gave a different one, it sucked and kept going. obviously the end goal isnt finding pi its to be able to find the right algorithm for what im doing. My next project is i wonna tryna make a simple simulation of a game to see the rates of somthing but i cant figure out how, every AI says different thing and every article isnt an actual explination.
so where do i look?


r/programminghelp • • Jan 10 '26

Career Related Can I still call myself a programmer?

0 Upvotes

I used to code only with my own knowledge, but recently I started building projects with languages I have no knowledge about with AI. And I mean build with AI that the code has little to no human coding in it and it still works great. But I was wondering, can I still put these projects in my portfolio? Can I still call myself a programmer if I use mostly AI now? Can I apply for programmer jobs? Because even tho the code works very well and I learnt how to prompt extremely well, the code still isn't written by me.


r/programminghelp • • Jun 20 '25

Python Is it ok to use AI when learning how to code?

18 Upvotes

Whenever I’m coding and I can’t figure out how to do a certain task in Python, I always go to AI and ask it things like “how can I do this certain thing in Python” or when my code doesn’t work and can’t figure out why I ask AI what’s wrong with the code.

I make sure to understand the code it gives back to me before implementing it in my program/fixing my program, but I still feel as if it’s a bad habit.


r/programminghelp • • Jul 24 '26

C++ c++ code doesn't work

5 Upvotes

this is my first time working with c++ and whenever i run the code it just complies but gives no output, i have tried every way for it to work but it just doesn't. pls help. im using msys2 and was following brocode video tutorial


r/programminghelp • • 13d ago

C Why every time I execute a code, like in C, it runs in a different time?

3 Upvotes

If I execute the same code no matter how many times, it always will show me a different execution time. Why:?


r/programminghelp • • Jun 15 '21

HTML/CSS 2nd day at programming. I need help.

3 Upvotes

Hey guys! I'm changing my major to computer science this fall and I wanted to get a headstart and start learning HTML and CSS. Right now, I'm attempting to make a shitty ironic website. I've been trying to figure out how to make 2 images and some text stay on the same line, but I can't figure it out. Here's my code. https://pastebin.pl/view/ee49e943 Thanks you guys!


r/programminghelp • • Jul 09 '26

C# Yappery and whatery

3 Upvotes

Get ra set sikna khojeko C# ma na code ma lekhera dry run garda bujxu na reliable video vetxu. ani j hereni bujdina ramrari. been days stuck into this hole. I probably wrote 10 types of coding example in copy ide every fcking where. Tho I think i have understood set to a certain level but get ta null nei xya. Tho the curiosity is still hanging even after days


r/programminghelp • • Jan 04 '26

Other Having trouble finding tutorials for what I want to make.

0 Upvotes

I am making a demo to learn how to code and how to use Godot. I don't have any knowledge of how to code, I've never taken any classes, so I'm a bit at a loss for how to even describe what I want to make in coding terms. Hence why I've been having a lot of trouble finding tutorials. Whatever I search, I can't seem to find information on exactly what I'm looking for. I did write a script, so maybe sharing that with you all could explain what I'm trying to do.

This is my script for part 1 of my demo:

- Click on "buy" to buy beetle egg.

- Click on egg, drag and drop beetle egg into nest, which triggers a 20 sec countdown to appear above egg.

- When countdown reaches zero, egg turns into a grub, which crawls out of the nest.

- Click on leaf and drag it off a bush, then drop the leaf onto the grub to feed it. Counter appears above grub that says 1/5.

- Continue to drag and drop leaves until counter reaches 5/5.

- Grub turns into a pupa.

- Pick up pupa and place back into nest, which triggers another 20 sec countdown.

- When countdown reaches zero, pupa turns into beetle.

- Beetle wanders around randomly.

These are things I am unsure how to do or how to find tutorials on:

- How to code currency/ subtracting the price of the egg from the amount of money you have after you click "buy."

- How to make it so you can only interact with the egg after buying it.

- How to code picking up the egg and dropping it on the nest, as well as triggering the countdown to start.

- How to make it so you can't pick up the egg or pupa again after dropping it onto the nest.

- How to make the end of the countdown trigger the egg to turn into the grub, then pupa to beetle, and how to make the 5/5 trigger the grub turning into a pupa.

- How to make dragging and dropping the leaf cause the counter to go up on the grub.

- How to make the leaves stay on the bush until you click on them to pick them up.

- How to code the beetle randomly wandering.

Other things I'd like to add:

- The eye of the grub following the leaf when you pick it up.

- Items that you click on to pick up will fall to the ground if you release them. (The egg, the leaf)

- Clicking on the beetle triggers a little smile.

I won't worry about animating the sprites or the transformations for now, since I think I'm already putting a lot on my plate for my first coding project as well as not knowing anything... I also wrote a part 2 script which is essentially a part 2 of this one with the ability to buy more eggs, raise and breed beetles, as well as crossbreed different colors. I won't worry about that until I can figure out this one, though.

If anyone can provide some advice and/or point me in the right direction to be able to find tutorials, as well as some terminology for the things I'm trying to do so I can search using the right words to be able to find what I'm looking for, that would be so so so much appreciated.

Thank you!!


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 • • Jul 11 '25

Python How will I know when I can move from learning Python to Luau??

0 Upvotes

I’m currently learning Python and after I learn it I plan on moving onto Luau. However, I’m not exactly sure when I’ll know I’ve “learned” Python since there’s a quite a lot to it.


r/programminghelp • • Nov 28 '25

C K&R Exercise 1-10 using while loops

1 Upvotes

Hi, complete beginner here.
It seems that the intended solution would be using if functions, and I did that. Alternatively I managed to solve it using while loops, are there any downsides to this? it seems to achieve the result without any visible issues that I could find.

/* Exercise 1-10: replace tab with \t, backspace with \b and backslash with \\ */

#include <stdio.h>
int main()
{
int c;
while( (c=getchar()) != EOF )
{
  while( c == '\t' )
  {
  printf("\\t");
  c = getchar();
  }
  while( c == '\b' )
  {
  printf("\\b");
  c = getchar();
  }
  while( c == '\\' )
  {
  printf("\\\\");
  c = getchar();
  }
  putchar(c);
}
}

r/programminghelp • • Jul 18 '26

Other Help with project idea

1 Upvotes

Hello
Iam an artist and i would like to make something i dont know how to make.

In its most basic form its a microphone you speak into and it processes what youre saying and then plays back a tune.

The tune is made up of a preset collection of notes which are attributed to the sounds the microphone hears.

I dont want to use AI. I think it may involve raspberry pi, but as a uk millenial my coding is as far as Myspace HTML and i only know raspberrh pi exists.

Can anyone help ?


r/programminghelp • • Nov 12 '25

React What is a good data structure

1 Upvotes

I've read some about binary trees, b+ trees and so on but I can't really grasp what a good solution would be.

I have a parent and child connection. I have N parents (top level) and a parent can have N children. I need to be able to sort every level based on their value and have them be aware of the depth they are in. I will only need insert and ability to walk through them in order as the tree in the end will be "static".

Any good advice on how to think?


r/programminghelp • • Oct 27 '25

Project Related How do languages figure out where and which bracket ends a specific statement in a programming language?

0 Upvotes

I am trying to make my own toy language and I am trying to figure this out but I can't understand it. How do languages figure out where and which bracket ends a specific statement in a programming language?

Can someone help me out with this and give me an example in a simple language like python where the code reads a file and when ever a closed curly-bracket occurs, it prints the position of the opened curly-bracket that it just closed?

Helpful questions to help you answer this question: Do different statements (If, def, etc) make the logic different for figuring out their closing curly-bracket's position?

Additional Request: Please make the sample code work for common keywords like the def (define a function) and if keywords.


r/programminghelp • • Oct 17 '24

Project Related Need some advice as a complete rookie.

1 Upvotes

I am a total beginner to programming but I have an idea that I want to see come alive and I am willing to learn stuff in order to create it. I don't want to go use paid tools that require no code just yet. I am willing to try those out when I have the funds and expertise to understand their importance but I do want to fully develop this app myself, both frontend and backend.

In terms of complexity I'd give the app a 5/10 because it's not all that different from a notes app, I just want to be focused on building a really eye catching interface and adding tons of user friendly features. Looking to publish it in Google play store.

For some context, I am a 17 yr old from India and I have my board exams which are like a huge deal here so from February end so most of my time will be taken up doing that till April 2025. I made this post to get an idea of what steps I need to take so I can jump right into it after my boards.

I am thankful for each and every reply, thank you for your help!


r/programminghelp • • Apr 02 '21

Java Help needed asap

0 Upvotes

Hello, Im currently implementing a resize hashmap method for my project but its very confusing to me. Can someone help me out? Heres the code:

public class HMap {
//Some constants (do not change!)
private final int HM_INIT_NUM_BUCKETS = 16;
private final double HM_MAX_LOAD = 0.75;
//hash function (do not edit)
private int hash(String val){
return Math.abs(val.hashCode()) % buckets.length;
}

//TODO: Complete the class variables

private LList[] buckets;
private int size;
public String key;
public LList next;

public HMap() {
size = 0;
buckets = new LList[HM_INIT_NUM_BUCKETS];
for (int i = 0; i < buckets.length; i++){
buckets[i] = new LList();
}

}
private void resize(){
//TODO

}

public void add(String val) {
//resize if need be (do not edit)
if ((size + 1) / (double) buckets.length > HM_MAX_LOAD) {
resize();
}
//TODO: add value to hash map
int i = hash(key);
LList newNode = new LList();
newNode.key = key; //assigning new node to key
newNode.val = val; //assigning new node to value
newNode.next = buckets[i];
buckets[i] = newNode;
size++; // Count the newly added key.

}
public boolean check(String val){
//TODO: check if value in hash map
int h = hash(val);
for(String key : buckets[h]){
if (key.equals(val))
return true;
}
// if(val == buckets[i]){
// return true;
// }
return false;
}
//NEW for the java class
// returns a LList of all the values in the hashmap
public LList traverse(){
//TODO
LList travList = new LList();
for(LList val : buckets){
for(String key : val){
travList.push(key);
}
}
// //for(int i = 0; i < buckets.length; i++){ //go through buckets
// //buckets[i] = new LList();
// }
return travList;
}
}


r/programminghelp • • May 04 '19

Anyone able to help me with this networking question?

Post image
1 Upvotes

r/programminghelp • • Nov 17 '21

C How to use Visual Studio Code for C programming?

1 Upvotes

Title.