• Breaking News

    Tuesday, March 16, 2021

    If I am agreeing to help someone with programming. Would I get in trouble if they are trying to share their company’s code to me ? Ask Programming

    If I am agreeing to help someone with programming. Would I get in trouble if they are trying to share their company’s code to me ? Ask Programming


    If I am agreeing to help someone with programming. Would I get in trouble if they are trying to share their company’s code to me ?

    Posted: 16 Mar 2021 12:04 PM PDT

    Person wants me to view issues with code. Code is that of the company they work for. Do I suffer repercussions in any scenario?

    Obviously I am trying to solve problems so in a way I am helping them. But I know the law exists and don't know if I could possibly get in trouble.

    submitted by /u/PaleHazy
    [link] [comments]

    I'm uneducated in programming terminology. Would someone mind answering a question?

    Posted: 16 Mar 2021 08:34 PM PDT

    For starters, I chose reddit because it seems like a much smarter place to ask for advice rather than using google, and because google itself is terrible at guessing what I'm looking for, especially when I myself don't know proper terminology to find what I'm looking for.

    For context, I'm planning on learning some light programming because there are several future projects I'm getting into that require knowledge of resistor color bands and identifying the right resistors. Unfortunately, that info is either contained in an image, or an online "calculator". Sure, I could download an app to my phone for it, but I would like to create a simple standalone executable for my laptop that I can launch and use even if the laptop is not connected to the internet.

    With that out of the way, I'd like to learn a few things if that's alright.

    The question I would like to ask is about what a software window is actually called. What I mean is, you know when you launch any software in a window, and everything in that software is contained within a big box with a big red X at the top right corner, along with the minimize button and fullscreen button.

    What is this window actually called in programming?

    I would like to learn this so that I might better utilize google to research how to create one for myself.

    submitted by /u/Nonchalant_Shallot
    [link] [comments]

    How does my computer differentiate between different programming languages? How does a computer treat different file extensions?

    Posted: 16 Mar 2021 08:56 PM PDT

    If I write code in a text editor, and save it under a certain file extension, how does my computer know what type of code should be running? How exactly does a computer differentiate between, say, Java code, JS code, CPP code, etc.?

    Does it compare the code to a database? Is the computer programmed to know based on the file extension?

    Moreover, how do file extensions work? How does my computer recognize file extensions and format the file accordingly?

    submitted by /u/imstillmb
    [link] [comments]

    What languages do I need to create a simple text adventure program?

    Posted: 16 Mar 2021 10:45 PM PDT

    Hi,

    I want to create a simple text adventure program where the program prompts the user with a given set of choices. For example:

    "You reach the door.

    a) Knock.

    b) Open without knocking.

    c) Put your ear to the door and listen"

    I have been learning Python, but is that the best language? lol

    Ideally this would be an app, but embedded on a website would be fine, like here: (http://psych.fullerton.edu/mbirnbaum/psych101/Eliza.htm)

    I feel there may be a simple way to do this and I'm making it needlessly difficult.

    These are the languages I've considered:

    • Python
    • C#
    • Javascript
    • SwiftUI

    I have no idea what i'm doing dog.jpg

    Am I on the right track with Python...?

    submitted by /u/emerald_python
    [link] [comments]

    What to do after learning coding ?

    Posted: 16 Mar 2021 10:35 PM PDT

    I am not sure if this is the right place to ask, but anyways I am posting it here:

    Since this the pandemic, I have been learning to code (mostly from youtube and some websites) mostly in C++ and python. Apart from learning the syntax of the language, I have also learnt about quite a few data structures and algorithms.

    At this stage I didn't know what to do next, so after a few google search I start solving questions in sites like hackerrank, leetcode and geeksforgeeks. (I am not much interested in competitive programming)

    But I actually don't know how software development works in the industry, so I was hoping if someone could guide me on what do I do next ?

    One of the things that I found online was something known as software development cycle, which start from requirement, making the product, testing and delivering it to the customer. Could someone suggest any tutorial or guide about this preferably with examples ?

    I am sorry if this post sounds vage, I am fairly new to this stuff and learnt most of them from youtube, any help would be greatly appreciated. Thanks in advance

    submitted by /u/XMP_404
    [link] [comments]

    We have VoIP, voice over IP. Why don't we have IP over voice? Eg. Internet is restricted, but voice calling is not. Can we write drivers to enable internet across audio signals? This situation is not hypothetical in Myanmar.

    Posted: 16 Mar 2021 10:26 PM PDT

    It'll most likely involve audio processing for conversion between audio signal and bits, and also a network adapter to integrate with the OS. System A would have internet and System B would get internet through System A through an audio channel, perhaps through a phone call.

    submitted by /u/-DivineGod-
    [link] [comments]

    adding rows in java

    Posted: 16 Mar 2021 10:14 PM PDT

    i am trying to add the numbers in a row in java using a loop, but i am drawing a blank. can someone point me in the right direction?

    for example:

    mon. tues wed thurs fri sat sun total/week.

    1-2min 2-3min 3-1min. 4-8min. 5-1min 6-3min 7-2min. 20min

    how can i add the total minutes?

    submitted by /u/Successful_Draft2071
    [link] [comments]

    Quick question, is there something I can use to build a web interface to control my PC? I need to be able to launch applications at least. Is there a ready-made tool that I could use to intercept commands from a web interface?

    Posted: 16 Mar 2021 09:50 PM PDT

    I'm thinking of something like I go to http://domain.com/?q=my%20command and it executes on the remote PC. I was thinking of just parsing the apache logs or something. I am sure there's something better than that.

    I'm aware of the security concerns, it's just for a proof of concept so security is not a priority.

    I tried exec in php, it's a bit unreliable, it also won't work unless I use psexec to spawn the window inside the current user session, which also doesn't seem to work well with stuff like batch scripts.

    Is there a ready-made tool for doing this?

    submitted by /u/thro_a_wey
    [link] [comments]

    Migrating to Javascript from a (very basic) background in C

    Posted: 16 Mar 2021 09:16 PM PDT

    Apologies if this is a little incoherent.

    So I've done Harvard's CS50 course which mainly focusses on C. It does a tiny bit of Javascript at the end, but it was pretty minimal, so it didn't really stretch me. I'm now trying to improve my knowledge of Javascript by doing some of the exercises on freeCodeCamp. One of the things that's really tripping me up is that I can't see my output in a terminal. When I was using C or python in the CS50 IDE, I could tinker with my programmes and use the output in the terminal to diagnose what was wrong, but currently I'm not able to use this feedback.

    Is this a result of fCC's interface or is it related to Javascript specifically?

    I tried downloading Visual Studio Code but I'm struggling to figure out how to use it, is this what I want or am I on the wrong track? I've also heard of Node.js? I'm feeling quite lost.

    Any help would be much appreciated.

    submitted by /u/Blue_Khakis
    [link] [comments]

    MQL4 (C++) Calling method from parent class that calls methods in child class

    Posted: 16 Mar 2021 02:53 PM PDT

    Good evening, I am a beginner programmer and I'm having an issue with MQL4. This language is said to be very close to C++.

    From the OnTick() function (serving as the main function), I am creating an object of struct EAObject. This object is then passed to the child class MeanReversion of parent class StrategyObject class. MeanReversion class inherits the Manage() method from StrategyObject.

    class StrategyObject { protected: virtual bool Scan(EAObject &object) { return; } //Don't use this Scan()! Use the child Scan() instead! virtual bool Initialize(EAObject &object) { return; } //Don't use this Initialize! Use the child Initialize() instead! public: void Manage(EAObject &object) { if ( Scan(object) ) { Initialize(object); } } }; class MeanReversion : public StrategyObject { virtual bool Scan(EAObject &object) override { //Use THIS Scan() } virtual bool Initialize(EAObject &object) override { //Use THIS Initialize() } }; void OnTick() { EAObject GBPJPY(""); //removed values for ease of reading MeanReversion::Manage(GBPJPY); } 

    Unfortunately, when I try to call MeanReversion::Manage(GBPJPY); from the OnTick() function, an error is returned which reads, 'Manage' - access to non-static member or function.

    DISCLAIMER: I have googled this thoroughly and done my own experimentation without result.

    Thanks for reading and I appreciate constructive criticism.

    submitted by /u/2_stepsahead
    [link] [comments]

    Website that retrieves arguments over the web, performs calculations on a hosted executable, and displays the results in a JSON file

    Posted: 16 Mar 2021 08:46 PM PDT

    UPDATE: Had an issue with launching the executable, solved this specific issue by changing the directory of my executable. Below is before fixing the issue.

    I'm trying to make a REST API that receives parameters from URL and then will run a hosted executable (written in C++) based on those parameters. The executable will then do all of the heavy-weight calculations necessary and write a JSON file as output for the user.

    I have been trying to set up Python Django server with that in mind, but most of the tutorials I've seen have been centered around making database APIs, and I've been having issues with running the executable hosted on Django. I've been trying to find help for my specific issue but I have found very little.

    Is there a simple way to perform this? I'm currently only looking to build a bare bones website that can host my executable and act as a REST API.

    For context: I have roughly 1 year amateur C++ experience, and a preference for learning Python in the future.

    submitted by /u/HaroldBUTTERSWASH
    [link] [comments]

    How to check if K consecutive element of a string are in a dictionary in Python?

    Posted: 16 Mar 2021 03:39 AM PDT

    Basically, I've got a string in Greek and another in Italian, and a dictionary in whit translation from Greek to Italian.

    I want to find out sequences of at least k > 0 words in the Ancient Greek text such that they correspond to sequences of at least k words in a paragraph of the Italian text, only if translated in the given dictionary, but keeping punctuation in the answer.

    I've tried splitting the texts word by word, but sadly some word of the Greek text are longer then a word from the Italian text, so I can't split the italian text as well (ie: 'ἁμόθεν': 'da qualunque principio')

    For now, I can find if a word is in the greek text and has a translation in the dictionary which is present in the italian text, but can't go any further. i need to find K consecutive word like that

    Have you guys any indication for the direction i can try to go?

    submitted by /u/gabbo993
    [link] [comments]

    Can someone explain this PHP function, and is there any better way to fetch an API response (in XML format) of weather data and display it as a HTML table?

    Posted: 16 Mar 2021 07:31 PM PDT

    function curl($url) {

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

    $data = curl_exec($ch);

    curl_close($ch);

    return $data;

    }

    $urlContents = curl("http://api.openweathermap.org/data/2.5/weather?q=Swansea&type=accurate&appid={APIKEY}");

    $weatherArray = json_decode($urlContents, true);

    $weather = "Currently ".$weatherArray['weather'][0]['description'].".";

    $tempCel = intval($weatherArray['main']['temp'] / 9/5 + 2);

    $speedInMPH = intval($weatherArray['wind']['speed']*2.24);

    $weather .=" The temperature is ".$tempCel ."° C with a wind speed of ".$speedInMPH." MPH.";

    submitted by /u/JJosuke434
    [link] [comments]

    OOP

    Posted: 16 Mar 2021 07:28 PM PDT

    class Author {

    // MUST have ID (int), name (string) and email (string) as private fields.

    Public: // add necessary methods including setters and getters,

    // AND/OR declare friends, so that the given main() works

    };

    class Book {

    // MUST have title (string), ISBN_No (string), price (float) and the following as private fields.

    Int noOfAuthor;

    Author *ptr;

    Public: // add necessary methods including setters and getters,

    // AND/OR declare friends, so that the given main() works

    };

    int main()

    {

    Book b1, b2("Data Structures", "978-0-7334-2609-4", 550);

    //parameterized constructor also ask for no of authors and their details

    cout << "Give input for book 1: " << endl;

    cin >> b1;

    //Should ask title, ISBN_No, price.

    //Then ask #ofAuthors & author info (id, name and email) for all authors.

    cout << "Complete information of the books are: " << endl;

    cout<< b1 << b2 << endl;

    cout<<"For The book titled: "<< b1.getTitle() <<endl;

    if(b1 <= 1000 || b1 == "Ataul Karim")

    cout<<"Ataul Karim is an author, or the price is <= 1000"<<endl;

    else

    cout<<"Ataul Karim is NOT an author & price is > 1000"<<endl;

    return 0;

    }

    So our professor gave us this practice problem for my oop course. I understood how to do everything except for the part in cin and cout operation because when i use two methods for cin and cout how do i access the Noofauthors because by then it already goes to the method where the parameter is Author pointer so I can't access the number of authors.

    istream&operator>>(istream &myIn,Author *a)//passed by author class pointer reference

    {

    /*cout<<a<<endl;

    cout<<a[0].ID<<endl;

    a[0].ID=32;

    cout<<a[0].ID<<endl;*/

    cout<<"Enter the size: ";

    int len;

    myIn>>len;

    for(int i=0;i<len;i++)

    {

    cout<<"Enter details for author number "<< i+1 <<": "<<endl;

    cout<<"Enter ID: ";

    myIn>>a->ID;//The way to access pointer array index by . not ->

    cin.ignore();

    cout<<"Enter name: ";

    //myIn>>a[i].name;

    getline(myIn,a->name);

    cout<<"Enter email: ";

    getline(myIn,a->email);

    a++;

    }

    return myIn;

    }

    istream&operator>>(istream &myIn,Book &b)

    {

    cout<<"Enter the number of authors of the book: ";

    myIn>>b.noOfAuthor;

    b.ptr=new Author[b.noOfAuthor];

    //cout<<b.ptr<<endl;

    myIn>>b.ptr;

    return myIn;

    }

    how do i access the number of authors when the pointer is being passed as a parameter.

    cin>>b1 and cout<<b1 are the things i can't solve . Please help.

    submitted by /u/Bored_ladd
    [link] [comments]

    Unhandled exception using csv reader next function

    Posted: 16 Mar 2021 06:53 PM PDT

    Hello, I feel like this is a basic problem with hopefully a basic answer I'm just completely stumped. The first two iterations of reader.next() work but the first one in the while loop does not. It seems to be the loop causing the problem but not sure why. I tried clearing the variable current (which is a list) beforehand to no avail. Anybody got any ideas? Thanks!

    https://paste.ofcode.org/tzgpR5rZvVXvgzrgcf5yAL

    submitted by /u/cashdelight69
    [link] [comments]

    (Qt/C++/QTcpSocket) Does QIODevice::readyRead() emit a signal when bytes are still in the socket buffer but no data was received since its slot function was last invoked and returned?

    Posted: 16 Mar 2021 05:32 PM PDT

    any data arrives to the socket buffer, QIODevice::readyRead() emits and invokes processSomeData().

    Let's say that processSomeData() reads all bytes, thus making skt->bytesAvailable() to return 0.

    processSomeData() returns to, I assume an abstracted event loop.

    New data arrives, rinse and repeat.


    But let's say QIODevice::readyRead() emits and invokes processSomeData(). and we process only some data, but no new data arrives after processSomeData() returns...

    is QIODevice::readyRead() still emitting, or will it emit in this case?

    If not, how must one properly handle this without any dirty recursion, such as re-calling processSomeData() when skt->bytesAvailable() still returns non-zero?

    submitted by /u/MintChocolateEnema
    [link] [comments]

    A chance to ask Spring and Liberica JDK devs a few questions

    Posted: 16 Mar 2021 09:32 AM PDT

    On March 25th we'll have Josh Long (Spring Developer Advocate), Andrew Clement (Director on the Spring Engineering team), and Dmitry Chuyko (Performance engineer at BellSoft) who will explain how to:

    — Perform multi-faceted software optimization
    — Compile native code in Spring
    — Build the smallest container images

    They will also be glad to answer your questions, let us know what you're curious about!

    You will be able to watch the whole event here: jrush.bell-sw.com

    submitted by /u/BELLSOFT
    [link] [comments]

    Advice on appropriate tool to use

    Posted: 16 Mar 2021 02:51 PM PDT

    Hello

    I am trying to design a program/other tool to automate preparing quotes. I know there is a lot of quoting software out there, but none of it seems to suit my needs. I am struggling to identify the right tool to build this and would appreciate some advice / points.

    At the moment I do all of this in excel, which is pretty much fine for (1) and (2) but laborious for (3) and (4).

    What I would like to happen is:

    (1) User provides initial information about new quote request:

    - Job name

    - Proposed job stages (e.g. "Draft memo")

    - Proposed job substages (e.g. "Initial research", "First Draft", "Prepare bibliography")

    - For each substage, how many hours each team member will spend on it (e.g. Director - 5 hours; Manager - 2 hours; Assistant - 5 hours)

    - For each substage, any additional costs (e.g. Copying fees - USD 100)

    - What fee rates to apply (e.g. Director - USD 500 per hour; Manager - USD 350 per hour)

    (2) The tool prepares a draft quote

    (This is the easy bit - just some multiplication etc.)

    (3) The user can then review and amend the quote

    For example:

    - Add / delete a stage or substage

    - Amend the number of hours / cost for a substage

    - Change the rate applicable to the whole project

    - Apply an overall discount to the project (to be shown as a separate line item)

    - Insert / refine overall upper/lower bounds for the estimates

    (4) User can then finalise and output the quote in a chosen format

    For example:

    - Summary just showing stages and fee range for each stage

    - Summary showing stages and sub-stages, but only showing fee range for each stage

    - Full report

    As I say, I do all of this in excel and although I can re-use prior examples as templates, making changes and summarising the data is laborious.

    I have thought about Microsoft Power Automate, Excel, Google Docs, but also open to any other ideas you might have.

    Thanks in advance.

    submitted by /u/IMayDestroyYou
    [link] [comments]

    Hackerrank Append and Delete

    Posted: 16 Mar 2021 02:47 PM PDT

    I'm failing test case #5 and #10 for the following code.

    In #5, you're expected to translate y to yu in 2 steps. The expected output is no, but you can add u in one step (append a lowercase character). Similarly, in #10, going from 'abcd' to 'abcdert' should be 3 steps (it fails on hackerrank in 10 steps).

    BUT test case #3 'zzzzz' to 'zzzzzzz' passes just fine (just requires adding 2 z's).

    import math import os import random import re import sys def commonstem(s1, s2): i = 0 prefix = "" while i < min(len(s1), len(s2)): if s1[i] != s2[i]: break prefix += (s1[i]) i += 1 return prefix def appendAndDelete(s, t, k): stem = commonstem(s, t) slen = len(s) tlen = len(t) stemlen = len(stem) print(stem) if s == t: ops = 0 elif stemlen > 0: if slen - stemlen == 0: ops = (tlen - stemlen) else: ops = (slen - stemlen) + (tlen - stemlen) else: ops = slen + tlen print('ops', ops) if ops <= k: return("Yes") else: return("No") if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') s = input() t = input() k = int(input()) result = appendAndDelete(s, t, k) fptr.write(result + '\n') fptr.close() 
    submitted by /u/LostBadger8720
    [link] [comments]

    I'm completely new to programming and decided to learn python. Where do I start?

    Posted: 16 Mar 2021 02:38 PM PDT

    Should I get books on programming or learn somewhere online?

    submitted by /u/Tim72861
    [link] [comments]

    API for retrieving product page data

    Posted: 16 Mar 2021 02:05 PM PDT

    Hello, I'm not an avid web dev so I know very little about this, but I'll try to explain my needs in the most proper way possible. Anyway, I'm looking for an API that can retrieve data from a product's page and then be pasted into another website's profile form.

    Use case; I'm making a test format of a profile setup, but I want the user to be able to upload a pre-existing store's values, like; Pictures, Product Information, and Price? - An Iframe basically.

    I found "Ecwid" which seems to be an option but it comes with a hefty price tag, which I'm not going to pay just for a test-run. I'm also not looking for the checkout input, only the data displayed on a product's page (Pictures, Information & Price).

    Appreciate it if you know any good API/Iframe that can do this, and is also optional for Amazon, Facebook, Alibaba, Shopify.

    submitted by /u/SoftTechnology4
    [link] [comments]

    Tools to emulate mono-repo with a poly-repo?

    Posted: 16 Mar 2021 12:42 PM PDT

    I am hoping someone has come up with a tool to emulate the benefits of a mono-repo while working within several separate repos. Usually when I come up with an idea, someone else has done it.

    I image a CLI command, like mrepo, that has similar sub-commands as git but executes them across all projects within the same organization. If such a thing doesn't exist I may write it. It could also be done with git-hooks, but I worry that could cause confusion.

    You'd have a root dir for your org (e.g. ~/src/usinc) and subdirs for each project (e.g. ~/src/usinc/mainapp). These sub-commands would run across all sub-projects, if you've cloned them. (You aren't required to have all repos locally.) Most of these sub-commands will fail if all repos aren't on the same branch name.

    Sub-Command example Description
    clone <repo...> Clones one or more repos into the root dir.
    checkout develop Checks out develop in current project and all other repos.
    checkout -b <branch> (or branch <branch>) Creates the branch in current project and all other repos. Records original parent branch name in .git/config.
    fetch-parent Fetches parent branch across all repos (e.g. "git fetch origin develop:develop"). Is recursive (e.g. also might call git fetch origin master:master)
    commit Commits across all repos
    push [--tags] Pushes all repos, only if any new local commits (or tags) exist.
    sync Attempts to get all other repos into same branch as yours, and also calls fetch-parent. Ensures all repos know their parent branch (in .git/config).
    make build Builds all projects, and creates artifact symlinks across directories (e.g. node_modules, or target/lib), similar to npm link, so you can get benefits of a mono-repo. Build order will be based on dependencies. This will require a Makefile for all projects.
    tag Tag across all repos

    Git can still directly be used, but a git hook will disallow a push if repos' branches aren't in sync.

    Why not just use a monorepo?

    • We want to be able to restrict access per project. This is biggest reason.
    • Many build tools and VCS tools aren't designed for a mono-repo workflow, requiring niche solutions
    • Easier management of separate ticket and CI data stores.

    This should have the pros of both poly-repos and mono-repos, but without most of the cons. However, it will require complex logic for sharing artifacts and running cross-repo builds in the proper order.

    submitted by /u/funbike
    [link] [comments]

    Compare two string, need the punctuation from one, but has a bunch of word i don't need

    Posted: 16 Mar 2021 12:00 PM PDT

    Still me. I'll try to explain myself as good as possible.

    Basically, I got two string. In the first one, i got many characther i don't need, in the second i got only the letters i need but no punctuation.

    There is a way to 'take' the punctuation from the first one?

    IE:

    1) "buongiorno, mi chiamo giorgio, ho 36 anni, e vengo da roma. vorrei mangiare qualcosa, c'è un tavolo libero?"

    2) "mi chiamo giorgio ho 36 anni e vengo da roma vorrei mangiare qualcosa"

    What i need is:

    "mi chiamo giorgio, ho 36 anni, e vengo da roma. vorrei mangiare qualcosa"

    Do you know a way?

    submitted by /u/gabbo993
    [link] [comments]

    How would you personally code something like this?

    Posted: 16 Mar 2021 03:53 AM PDT

    It's an overworld view in a game- theres one gray path zig zagging to different levels. You beat the level and the path behind it turns yellow or gold or something. While the path in front of you is still grey (unexplored)

    I'm playing some mobile game and I'm trying to figure out how they did it....

    Maybe they swapped a grey PNG for a gold one?

    Maybe the background is layered and the grey trail is transparent but they draw in a yellow square inbetween the layers so it gives that effect

    Hmmm. I'm curious how you all would make something like that

    submitted by /u/OliveOilOverdose
    [link] [comments]

    Exited, segmentation fault error! gah!!!

    Posted: 15 Mar 2021 10:06 PM PDT

    I'm trying to make an anagram program and it keeps saying "exited, segmentation fault". I'm so confused any help is greatly appreciated. I know there's lots of notes but my teacher requires it.

    #include <iostream>
    #include <cstring>
    #include <string>
    using namespace std;
    // Constant
    const int ALPHA = 26;
    // Reference parameters
    void occurence(string word, int count[]);
    bool equal_array(int count1[ALPHA], int count2[ALPHA]);
    // Main function
    int main() {
    // Variable definitions
    string firstWord = " ";
    string secondWord = " ";
    int firstCount[ALPHA];
    int secondCount[ALPHA];
    int firstLen = 0;
    int secondLen = 0;
    // Welcome message
    cout << "Welcome to my anagram program!!" << endl << endl;
    // Get two words as user input
    cout << "Please enter your first word: ";
    cin >> firstWord;
    cout << "Please enter your second word: ";
    cin >> secondWord;
    firstLen = firstWord.length();
    secondLen = secondWord.length();
    // Call function to count occurences of letters in words
    occurence(firstWord, firstCount);
    occurence(secondWord, secondCount);
    // Call function to compare the counts of the letters of the words
    if (firstLen == secondLen) {
    if (equal_array(firstCount, secondCount)) {
    cout << "These words are anagrams!" << endl;
    }
    else {
    cout << "These words are not anagrams." << endl;
    }
    }
    else {
    cout << "These words are not anagrams." << endl;
    }
    return 0;
    }
    // Returns array of counts of each letter
    void occurence(string word, int count[]) {
    for (int i = 0; i < ALPHA; i++) {
    char letter = word[i];
    count[letter - 65]++;
    }
    }
    // Tests both arrays for equality
    bool equal_array(int count1[ALPHA], int count2[ALPHA]) {
    for (int i = 0; i < ALPHA; i++) {
    if (count1[i] != count2[i]) {
    return false;
    }
    }
    return true;
    }

    submitted by /u/meeeeee0w
    [link] [comments]

    No comments:

    Post a Comment