r/programminghelp • • Sep 13 '25

C++ Second month c++ student seeking help on an assignment

9 Upvotes

The assignment calls for me to read several names, and then sort them alphabetically.

My professor has stated that using concepts that we haven’t covered will result in a failed grade. She cited arrays specifically as an example.

Through some google search, I discovered an index operator that accomplished what I needed to do:

char = firstInitial; string = fullName;

cin >> fullName; firstInitial = fullName[0]

However, I’m now afraid that I’ll fail the assignment because our book hasn’t yet covered this indexing operator. I’m sure there is a way to accomplish this using cin, and I’m just not experienced enough to see it yet.

To maintain academic integrity, would anybody mind nudging me in the right direction without writing the code for me? I understand that you reading this won’t know what we have and haven’t covered in class. If I see something that appears unfamiliar to me, I’ll let you know.

This feels like a big ask, and I apologize for coming off as naive, but I don’t have the skill or knowledge to provide much else at the moment :(


r/programminghelp • • Jun 01 '25

Project Related Project Ideas Needed for a College Student that solves a real world issue and can be completed in a span of 2-3 months

9 Upvotes

Hello fellow redditers I wish not for take up too much of your time so I'll get to the point.. I'm a college student doing an Associate Degree in ICT and I was given a special project to find an issue in Jamaica or the world and provide a solution as well as implement it whether it be creating an app/ web app/ website etc. Thing is I have no idea what to do nothing is really clicking so I'm hoping for some ideas if possible. I believe the time frame to complete it will be 2 months.

I've been researching problems and going through whether Quora, online sites, I've even resorted to ai for ideas but nothing is clicking.

I was working on a project management app for clients and business owners but the ideas I have for it I won't be able to implement in that timeframe.


r/programminghelp • • Mar 03 '25

C++ Is this normal or am I cooked?

9 Upvotes

I study in computer engineering and I had the first coding class of my life. We learned the basics of c++ and it was pretty simple (the hardest project being a sorting algorithm for school grades).

Now... this semester I have a data structure class and right away after a 1 hour class on graphs, I'm supposed to make a program that simulate my whole city bus transport system. I don't know how to do that and now I'm stuck with 50 000 lines of json (I don't even know what this is) and I'm supposed to program this in a week for 30% of my grade


r/programminghelp • • Oct 06 '22

C# How would an Exception end the program despite being caught?

9 Upvotes

So I'm getting a "NullReferenceException", and visual studio highlighted the line "o = LocationsInViewport[y, x].ObjektsInLocation[0];", which is ironically in a try block. My point isn't to ask you to fix my entire program, unlike what a few condescending assholes who replied on stackoverflow assumed. I'm just asking how a "NullReferenceException" would end the program, despite the exception being caught. I've ruled out the possibility of the wrong line being highlighted by dividing the function into different try-catch blocks, as shown below.

public void UpdateDisplay()
{
       
    Objekt o = null;
    string GraphicName = " ";
    Texture2D GraphicToDisplay;
    try 
    { 
        Console.WriteLine($"Radius: {VIEW_RADIUS}");
        LocationsInViewport = UpdateVisibleLocations();
    }
    catch (NullReferenceException)
    {
        Console.WriteLine("Test");
    }
    try
    {
        for (int y = 0; y < VIEW_RADIUS * 2; y++)
        {
            for (int x = 0; x < VIEW_RADIUS * 2; x++)
            {
                try { o = LocationsInViewport[y, x].ObjektsInLocation[0]; }
                catch (NullReferenceException) 
                {
                    Console.WriteLine("Test2");
                    Thread.Sleep(8743843);
                }
                if (o != null)
                {
                    try
                    {
                        GraphicName = ObjektGraphixReferences[o.TypeID];
                        GraphicToDisplay = Content.Load<Texture2D>(GraphicName);
                        int MonoGameXPos = x / (VIEW_RADIUS * 2) * Nulandia.SCRN_WIDTH;
                        int MonoGameYPos = y / (VIEW_RADIUS * 2) * Nulandia.SCRN_HEIGHT;
                        o.SpriteDestinationRectangle = new Rectangle(MonoGameXPos, MonoGameYPos, o.WidthOnScrn, o.LengthOnScrn);
                        Nulandia.spriteBatch.Draw(GraphicToDisplay, o.SpriteDestinationRectangle, Color.White);
                        Console.WriteLine($"Position of object relative to screen: ({o.SpriteDestinationRectangle.X}, {o.SpriteDestinationRectangle.Y}");
                    }
                    catch (NullReferenceException)
                    {
                        Console.WriteLine("Is null.");
                        Thread.Sleep(8743843);
                    }
                }
            }
        }
    }
    catch(NullReferenceException)
    {
        Console.WriteLine("test");
        Thread.Sleep(8743843);
    }
}

EDIT: It was solved, for whoever else uses Visual Studio 2022 and has this issue, go to Debug > Windows > Exception settings, then find "Systems NullReferenceException" under "Common Language Runtime Exceptions" and make sure that the setting is switched off. Apparently it'll ignore the "catch" block and just end the program.


r/programminghelp • • Jul 29 '21

Processing ELI5 (if possible) How do MMORPGs handle so much going on concurrently from a coding / technology standpoint?

9 Upvotes

Basically title but for example how is a game like WoW or GW2 handling thousands / millions of players having xyz items and X gold at X time, using Y skill, etc. - all of this concurrently across the player base. Is new code constantly being created every action?


r/programminghelp • • Dec 24 '20

Other Choosing sizes in general.

9 Upvotes

Everywhere I go with programming, if I have to make a UI, I always need sizes, most often in pixels. If it's with percentages, I'm fine. But with pixels, I get this overwhelming feeling or something like it. It annoys me.

I can't seem to get explainations anywhere, and it really messes with my creativity

Since English isn't my main language, I just can't get to the terms for looking it up.

How do you all do this? How do you calculate how many pixels you need for a new window? Do you follow default sizes? Do I need to make myself a protocol with default sizes?

.


r/programminghelp • • Aug 18 '20

C++ What does Node** mean? and a few other questions regaarding linked lists.

9 Upvotes

Im reading a program to insert a node ate head of linked list from

https://www.geeksforgeeks.org/linked-list-set-2-inserting-a-node/

I have a couple of questions

1)what is the point of the last line? first line is initilising a new node,then you give it some data with arrow operator, then you make the newly initilised node link to the head,then what is the last step for?

2)what the heck is Node** head_ref supposed to mean in function parameters?

3)how would i implement this function?

/* Given a reference (pointer to pointer)  
to the head of a list and an int,  
inserts a new node on the front of the list. */
void push(Node** head_ref, int new_data)  
{  
    /* 1. allocate node */
    Node* new_node = new Node();  
  
    /* 2. put in the data */
    new_node->data = new_data;  
  
    /* 3. Make next of new node as head */
    new_node->next = (*head_ref);  
  
    /* 4. move the head to point to the new node */
    (*head_ref) = new_node;  
}  
  
// This code is contributed by rathbhupendra

r/programminghelp • • Sep 27 '19

I’m in an intro level programming class. I have to take even though my major is Social Studies Education. Our assignment is to make a form letter that get erased on a button click. For some reason, when I click the button, nothing happens. What am I doing wrong?

Post image
9 Upvotes

r/programminghelp • • Jul 18 '19

could someone explain me the __main__ thingy in python?

9 Upvotes

tried to read about it in a few sites but couldnt really understand why or how it works.


r/programminghelp • • 28d ago

HTML/CSS need a solution to an impossible problem

8 Upvotes

essentially, im tryna publish a public css website on a HEAVILY restricted school network

I'm developing a website which is essentially a student focused grade calculator that I've built using Python, Gradio, HTML, CSS, and JavaScript. ik there are other grade calcs out there, but this one is more specific to my district and solves the need of people constantly asking me to calculate their grades manually. The application itself is practically built, but I'm having a really difficult time figuring out how to actually publish it so other students can use it.

My requirements and limitations:

  • Students need to access it through one normal URL in their browser

  • No downloads, installations, or student accounts

  • AI website generators or a template builders are blocked

  • Student grade data needs to stay entirely in their browsers and not be sent to a server

  • It needs to be accessible on school computers, which have a VERYYYYY restrictive network filter

  • No paid hosting, adult involvement, administrator permissions, or requests to school IT

  • Ideally, I'd like a professional-looking URL that doesn't advertise that the site was made through an educational coding platform (ex. i know code .org is available and practically my only option but the name itself ruins the credibility. im ok with using if i HAVE to but i would rlly prefer not to)

I've already looked into A LOTTT of other options, including Google Sites, Google Apps Script, Firebase, Blogger, GitHub, and several other hosting platforms. either ALLLLL are blocked on school computers, or they don't actually support what I need. Google Colab works for development but im unable to publish past that

Does anyone have ideas for unconventional hosting or publishing methods that I might be overloking?


r/programminghelp • • Sep 28 '26

PHP How do I make a localhost when using a PHP file? Explain it to me as though I'm a four-year-old hamster of the verge of keeling over.

8 Upvotes

I'm trying to add data from an HTML form to a PHP database. I'm following this tutorial: https://www.youtube.com/watch?v=Y9yE98etanU. Here's my HTML and PHP code respectfully:

        <form action = "tutordata.php" method = "post">
            <label for = "name">First Name:</label>
            <input type = "text" name = "firstNameI" id = "firstNameI">
            <button type="submit">Submit Form</button>
        </form>

<?php


print_r($_POST);

Google says I need a localhost, but they aren't working so far. I have Live Server, but when I click submit it just brings me to an error message. When I run without debugging it shows me the raw PHP file instead of even an empty array. I did some stuff I don't even remember to make it so I could right click and do a PHP: serve project thing, but that didn't work. I tried doing some weird stuff with the terminal but I don't even know if I typed it in right. I have installed no less than three brand new extensions. I hadn't even heard of PHP before today.

Please just walk me through what I need to do step by step. I don't need to understand it, just give me some buttons to click. If I need to abandon PHP altogether, that's great too. I just need a database to put data in so I can have some freaking data.

I've never had to mess with this stuff before, so I'm clueless. I know HTML more or less, and Javascript is my baby, but the rest of it is Mandarin to me. I'm really not the computer person, I was just the most computer-adjacent person in the room at the time and was voluntold that I was doing this.


r/programminghelp • • Mar 30 '26

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

8 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 • • Sep 06 '23

Visual Basic Where can I find a list of every unicode character?

8 Upvotes

Hi everyone. Short and (hopefully) simple one. Where can I find a list of every unicode character? I've tried googling it but I don't get the full list or I get told how many there are.

I need the list to not have any labels (so I can just copy it into a text file)

For context, I'm using this to create a form of encryption I will use in an application.

Thankss (VB flair because that's what I'm using)


r/programminghelp • • Jan 19 '23

C++ Explain like I’m five: coding? C++?

8 Upvotes

I am a freshman aerospace student currently taking an “intro” coding class for c++ and Matlab

I’ve tried to learn any coding (c++, python) previously but have always found it not to be accessible, it feels like all the basic info isn’t basic at all

In fact to me learning c++ right now feels like if i was put in a physics class and had never taken math

I’m missing fundamental basics and everyone explains it to me in terms that are way too confusing, terms that aren’t beginner terms

What I am understanding is C++ is a language for coding and programming and that is the extent

But coding what? Programming what? Whenever I try to get an explanation I don’t even understand the explanation!

Even my textbook said “this textbook is not ideal for first time coders” but the class is suitable for students who have never coded

I don’t even know what coding is used for and “the following line says that main is a function with no parameters that returns an int (integer) value” means nothing to me and it was essentially the first thing in my textbook

I get that it’s like learning a new language but i don’t have any context in my brain and am struggling.

I am eager to learn and to try but need a little explanation into what it is i am even doing


r/programminghelp • • Aug 10 '22

SQL Railway.app alternative

8 Upvotes

For a very long time i have been looking for a good enough solution for hosting my MySQL database online but couldn't find anything.

Recently I came across railway.app felt like a good enough solution for me but had a lot of wierd bugs or quirks, like a 500 hour limit on the free plan, takes infinitely long to load a large database, and the application crashes even after trying to describe a table.

Is there any alternative to railway or any easy way to host my MySQL database for free?


r/programminghelp • • Jul 25 '22

Other How does a computer read English in code? Can it read other languages?

8 Upvotes

I was watching a friend code a game in Unity earlier today (something I know nothing about in the slightest) and with his various lines of code, he input a couple different English words at a time that told the game when to activate events and such.
How does a computer know how to read, and in what contexts? Also, is there coding in other languages (if so, is there a limited amount?)? Can you code in like Georgian script if you really wanted?


r/programminghelp • • Jul 25 '21

C# i want to create a bot that write random 6 digit number

8 Upvotes

i want to create a bot that writes random 6 digit number in notepad or any app with c#


r/programminghelp • • Feb 22 '20

C# Wont Replace Correctly

Post image
8 Upvotes

r/programminghelp • • Jul 30 '26

C++ Having trouble “ thinking in code”

7 Upvotes

I’ve been learning C++ for weeks, and of the concepts I’ve learned most if not all of them have clicked pretty quickly. I understand what they do and how they work.

However, when I’m trying to create something not from a tutorial or walkthrough, I’m having trouble translating my idea into the lines of code that will do what I envision it doing. Anyone have any advice on making the switch to more easily be able to “think in code”?


r/programminghelp • • Dec 18 '25

Project Related What’s the correct way to input to database, high level? Opinions welcome

7 Upvotes

Hi all, I have a mildly complex backend that can’t just add data and be fine. The data needs to be processed and old data needs to be shut off.

Currently:

Cronjob gets data —> adds all feeds to database queue —> cronjob calls edge function A—> edge function A pops from queue and adds data to database after processing —> cronjob calls edge function B for each feed —> edge function B cycles through old data in database to deactivate it

I feel like I’m both overcomplicating this process and yet also making it cleaner. I also only have 1 cronjob at the moment cause I don’t want 2 of them missing each other while working on the same thing. Basically, I’m asking if it makes sense for a cronjob to:

  • get data

  • call edge function A For each feed:

    • call edge function B

When each step kind of depends on the last one? If there are no updates to the data, I have the cronjob still call edge function A and B

Sincerely, Woe is my database


r/programminghelp • • Nov 26 '25

C a question about #define in C

7 Upvotes

Hi. Complete beginner here.
I was recently doing K&R 1.4 Symbolic Constants, the example code presented by the book is:

#include <stdio.h>
#define LOWER 0
#define UPPER 300
#define STEP 20

main()
{
  int fahr;

  for (fahr = LOWER; fahr <= UPPER; fahr 0 fahr + STEP)
      printf("3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));
}

I was wondering if why not #define the formula for celcius aswell. Thus:

#include <stdio.h>
#define LOWER_LIMIT 0
#define UPPER_LIMIT 300
#define STEP 20
#define CELCIUS (5.0/9.0)*(fahrenheit-32)

int main(){

    float fahrenheit;

    for(fahrenheit = LOWER_LIMIT; fahrenheit <= UPPER_LIMIT;
        fahrenheit = fahrenheit + STEP){
        printf("%6.0f\t%6.1f\n", fahrenheit, CELCIUS);
    }
}

Are there any foreseeable future issues I could have with doing this? Should I avoid it, or is it fine?

Thank you in advance for any answer.


r/programminghelp • • Jun 06 '25

Java I am taking intro to java programming in college, they use pearson revel to teach it. They basically expect you to learn it all from the book and give you a really bad enviorment which doesn't tell you why you have errors, and there are no resources from the professor. need advice

7 Upvotes

I took intro to programming or smth like that and there was no actual coding, It was just definitions, I got an A. Now that I am doing intro to java, they expect you to know how to code but I have very basic knowledge. The only way I can pass now is to have ai explain my errors to me which is not good longterm. next semester I have to take advanced java programming. What should I do. There are no lectures and very little help. The enviorment sucks and basically doesn't tell me why my code is wrong. and the coding assignments are so specific it is literally impossible. It completly does not feel like an intro class and I dont know what to do.


r/programminghelp • • Mar 26 '23

Python If python is looked down on as "slow", why is it used for neural networks?

7 Upvotes

I've just read that even openai uses it for chatgpt


r/programminghelp • • Apr 14 '21

Python Difficulty With Naming Files Written by Python

7 Upvotes

Okay so this is a bit complex, but here is the short version:

I am a psychologist who routinely conducts fMRI research. When doing fMRI research we have to create what are called "onset files" that tell the analysis software literally how long each event took on the screen in front of the participant so it knows when it should be looking for changes in activity.

To do this I have to take the raw .txt output file for each participant that I then feed into my python script that produces the onset files I need with naming conventions to make clear what they are.

In the current study I'm working on someone else made the task we used and the output is a bit different and for some reason it isn't cooperating with my script. In this task participants are shown text on a screen depicting a scenario and then they rate that scenario across 4 attributed on a scale of 1-4. There are five different types of scenarios: Disgusting, Harmful, Intentional, Accidental, and Weird. My aim is to have an onset file for the presentation of each type of scenario and one for the actual ratings So specifically, there should be 11 files for each participant (two for viewing and rating each type of scenario and another for the fixation cross they see between trials).

So my script is doing everything right - it's producing onsets that account for everything in the task time-wise...but it is dumping them all into just 2 files instead of 11. It grabs the name from the datafile properly and enters it into the file name...but stops making files after the first one and then just writes everything there. This is the "stimuli" object referred to in the script.

I know this is a lot of code to look at but I'm at my wits end with this - any help is greatly appreciated! I have tried to comment out what each chunk is supposed to do.

Also if any of you are thinking of doing psychology...avoid ePrime like the plague.

EDIT: Here is some fake toy data I made using the task that shows you what the file I am reading in looks like - https://drive.google.com/file/d/1xC1T2R1SG4j8RGq2u8GM-FEnV4lcF0Zm/view?usp=sharing

Code starts after this line

FIRST_PARTICIPANT = 101
LAST_PARTICIPANT = 101
EXPERIMENTS = 1 # number of CRT sessions
SHORT_EVENT_LENGTH = 2.5
LONG_EVENT_LENGTH = 5.0
LONGER_EVENT_LENGTH = 7.5
EXPERIMENT_DIRECTORY = "C:/Users/XXX/Desktop"
OUT_DIR = "C:/Users/XXX/Desktop/output/" 
LINE_ENDING = "\r\n"
TARGET_LABEL = "Level: 1"
FRAME_LABEL = "Level: 2"

fixTRLength = {
    1: SHORT_EVENT_LENGTH,
    2: LONG_EVENT_LENGTH,
    3: LONGER_EVENT_LENGTH,
}

def findLine(lines, shouldStartWith):
    '''find the next line number that starts with certain text'''

    for lineNo, line in enumerate(lines):

        # ignore lines that don't start with this text
        if not line.startswith(shouldStartWith):
            continue

        return lineNo

    raise ValueError(f"Couldn't find a line that starts with '{shouldStartWith}'!")

def getParameter(lines, parameter):

    for i, line in enumerate(lines):

        # ignore lines that don't start with the parameter
        if not line.startswith(parameter + ": "):
            continue

        return line.partition(" ")[2]

    raise ValueError(f"Couldn't find a parameter called {parameter} after line {i + 1}!")

def write_fixation(sessionTime, fixationLength, participant):
    '''write a line to the fixation file for this participant, returning
    the new running session time'''

    with open(f"{OUT_DIR}/IMG-{participant}-Fixation.txt", "a") as f:
        f.write(f"{sessionTime}\t{fixationLength}\t1" + LINE_ENDING)

    return sessionTime + fixationLength

def write1(sessionTime, participant, task, stimuli):
    '''write a line to the correct output file for this participant, returning
    the new running session time'''

    with open(f"{OUT_DIR}/IMG-{participant}-{task}{stimuli}.txt", "a") as f:
        f.write(f"{sessionTime}\t{SHORT_EVENT_LENGTH}\t1" + LINE_ENDING)

    return sessionTime + SHORT_EVENT_LENGTH

def write2(sessionTime, participant, task, stimuli, response):
    '''write a line to the correct output file for this participant, returning
    the new running session time'''

    with open(f"{OUT_DIR}/IMG-{participant}-{task}{stimuli}.txt", "a") as f:
        f.write(f"{sessionTime}\t{LONG_EVENT_LENGTH}\t1" + LINE_ENDING)

    return sessionTime + LONG_EVENT_LENGTH

def clean_response_number(numstr):

    '''Also for reasons beyond my comprehension, double-presses just PREPEND TO
    THE STRING, so only accept a maximum of one character.'''

    numstr = numstr[:-1][:1]
    if numstr:
        return int(numstr)
    else:
        return 0

for participant in range(FIRST_PARTICIPANT, LAST_PARTICIPANT + 1):
    for experiment in range(1, EXPERIMENTS + 1):
        print(f"== participant {participant}, experiment {experiment} ==")

        # make the output directory
        os.makedirs(EXPERIMENT_DIRECTORY + "/output", exist_ok=True)

        # read the whole this participant file into a list
        try:
            with open(EXPERIMENT_DIRECTORY + f"/JudgmentTask_FINAL-{participant}-1.txt", encoding="utf-16")         as f:
                lines = [ line.strip() for line in f ]

        # if you can't find the participant, write an error and move on
        except FileNotFoundError:
            with open(EXPERIMENT_DIRECTORY + "/skipped.txt", "a") as f:
                print(f"Missing experiment #{experiment} for participant #{participant}; skipping...", file=f)
            continue

        # running timer for the session
        sessionTime = 0

        startLine = 0

        # keep looking for target headers in the participant file until we can't find any more
        while True:

            # find the first line of the target header, starting at startingLine
            # these are actually below the trials for some reason??
            try:
                targetLine = findLine(lines[startLine:], TARGET_LABEL) + startLine

            # if we can't find any more trials, that's fine!
            # the experiment must just be over for this participant
            # move onto the next one
            except (ValueError, IndexError):
                break

            fixationLength = getParameter(lines[startLine:targetLine], "jitter")
            fixationLength = fixTRLength[int(fixationLength)]

            stimuli = getParameter(lines[startLine:targetLine], "ScenarioCondition")


            response = getParameter(lines[startLine:targetLine], "JudgeTrial1b.RESP")
            response = clean_response_number(response)


            sessionTime = write_fixation(sessionTime, fixationLength, participant)

            while True:

                try:
                    # find the line of the next trial (before the target line)
                    # searches for properties inside this trial will start from here
                    startLine += findLine(lines[startLine:targetLine], FRAME_LABEL) + 1

                # if we can't find any more trials before the target, that's fine!
                # move onto the next target header
                except (ValueError, IndexError):
                    break

                sessionTime = write1(sessionTime, participant, "Scenario", stimuli)
                sessionTime = write2(sessionTime, participant, "Rate", stimuli, response)
       
            startLine = targetLine + 1