• Breaking News

    Friday, October 4, 2019

    I got my first internship! learn programming

    I got my first internship! learn programming


    I got my first internship!

    Posted: 03 Oct 2019 10:10 AM PDT

    Hey guys, just wanted to say that I got my first internship at an IT company for the position of a front end web deloper. I am self taught and I've been studying actively for the past 8 months. So for anyone out there who's struggling, just keep studying hard and trust in yourself.

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

    Python Project with Source Code – Breast Cancer Classification with Deep Learning

    Posted: 03 Oct 2019 10:00 PM PDT

    If you want to master Python programming language then you can't skip projects in Python. After publishing 4 advanced python projects, DataFlair today came with another one that is Breast Cancer Classification project in Python. To crack your next Python Interview, practice these projects thoroughly and if you face any confusion, do comment, DataFlair is always ready to help you.

    Before we begin this Breast Cancer Classification Project in Python, let me provide you the list of advanced python projects published by DataFlair –

    Breast Cancer Classification Project in Python

    Get aware with the terms used in Breast Cancer Classification project in Python

    What is Deep Learning?

    An intensive approach to Machine Learning, Deep Learning is inspired by the workings of the human brain and its biological neural networks. Architectures as deep neural networks, recurrent neural networks, convolutional neural networks, and deep belief networks are made of multiple layers for the data to pass through before finally producing the output. Deep Learning serves to improve AI and make many of its applications possible; it is applied to many such fields of computer vision, speech recognition, natural language processing, audio recognition, and drug design.

    What is Keras?

    Keras is an open-source neural-network library written in Python. It is a high-level API and can run on top of TensorFlow, CNTK, and Theano. Keras is all about enabling fast experimentation and prototyping while running seamlessly on CPU and GPU. It is user-friendly, modular, and extensible.

    Breast Cancer Classification – Objective

    To build a breast cancer classifier on an IDC dataset that can accurately classify a histology image as benign or malignant.

    Breast Cancer Classification – About the Python Project

    In this project in python, we'll build a classifier to train on 80% of a breast cancer histology image dataset. Of this, we'll keep 10% of the data for validation. Using Keras, we'll define a CNN (Convolutional Neural Network), call it CancerNet, and train it on our images. We'll then derive a confusion matrix to analyze the performance of the model.

    Read More

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

    Error - I/O operation on closed file

    Posted: 04 Oct 2019 12:07 AM PDT

    Hi,

    I wrote this script, which extract specific chain from CIF file (using biopython) and I implement also information from yaml files, because to each CIF file there is yaml file where is written ID of the specific chain (because in each structure is the ID different). However I am getting error and I dont know why.

    Script:

    import Bio.PDB import yaml parser = Bio.PDB.MMCIFParser() io = Bio.PDB.mmcifio.MMCIFIO() cif_ID = "aaa, bbb" #there are many many more cif_input = cif_ID.split(", ") for ID in cif_input: dir_path = "/home/ME/Documents/something/{}/" .format(ID) cif_file = dir_path + "{}.cif" .format(ID) yaml_path = "/home/ME/Documents/something/{}/" .format(ID) yaml_file = yaml_path + "{}.yaml" .format(ID) with open(yaml_file, "r") as file: doc = yaml.load(f, Loader=yaml.FullLoader) chain_uL4 = doc["L4_chain"] structure = parser.get_structure("X", "{}.cif" .format(ID))[0] chain = structure[chain_uL4] #io = Bio.PDB.mmcifio.MMCIFIO() io.set_structure(chain) io.save(dir_path + "{}_uL4.cif" .format(ID)) 

    And the error is: I/O operation on closed file

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

    Are there any advantages of C# over Python?

    Posted: 03 Oct 2019 03:49 AM PDT

    I want to make a software for Windows which language should I choose C# or Python? Are there any advantages or benefits of using C# over Python or vice-versa?

    I want to make the software specifically for Windows.

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

    After college skills advice request.

    Posted: 03 Oct 2019 10:27 PM PDT

    I graduated college a couple semesters ago with a BS in compsci, and I'm now in the process of going through a security clearance for a government job (probably going to be waiting or months still), while working a couple teaching jobs right now for $$$.

    I'm concerned that what I think I know and my actual skill level in programming / computer science aren't equal and that my skills have been draining since my last classes. What would be some common advice for how to make sure I keep myself relevant?

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

    What is a useful language to learn alongside C#?

    Posted: 03 Oct 2019 08:02 AM PDT

    By alongside I mean what compliments it most and will look best to employers as well as make the most sense?

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

    Javascript Function Question

    Posted: 03 Oct 2019 08:23 PM PDT

    Hello, can you assess what's wrong my with code?

    Criteria:

    - Write a function named getWeekday() that uses a switch statement to display what day of the Week it is.

    - Hint: You can use the checked attribute on top of the getElementById() method. And you can use new Date().getDay() as the expression in your switch statement which evaluates to a number from 0 to 6 based on the day of the Week.

    This is my html file

     <b>Part 2: Finding out the Day of the Week</b> <br> <p id="output2">Display the Day of the Week here</p> <button onclick="getWeekday()">Click to get the day of the Week</button> </div> 

    This is my .js file function

    function getWeekday() { switch(new Date().getDay()) { case 0: day="Monday" break; case 1: day="Tuesday" break; case 2: day="Wednesday" break; case 3: day="Thursday" break; case 4: day="Friday" break; case 5: day="Saturday" break; case 6: day="Sunday" break; output2.innerHTML =today is+"day" } } document.getElementById('output2').innerHTML 
    submitted by /u/hizen_k
    [link] [comments]

    Bootcamp or solo?

    Posted: 03 Oct 2019 11:58 PM PDT

    My current security related job had an annoying and repetitive task that i though someone could automate.Over the next few months I ended up creating a tool in batch script that could take the input of a common name device (ala BTHC12-C1) and turn it into an ip address and ping it and return the result to the users clipboard for easy task completion.

    It was the most rewarding work experience i've ever had and it wasn't even part of my job. I'm teaching myself python now (finished a course that ran up to creating and using functions and classes) and i can already tell i want to do this for a living. The problem is im not sure how to turn the skills im learning into a job. I don't have the ability to take 4-8 years off for a CS degree. Even the 6 month bootcamps seem a stretch but i do think i can do it.

    My question is this: Should i go the bootcamp route to get a job or is it possible to get hired with just a portfolio that demonstrates your skill?

    submitted by /u/Orthodox-Waffle
    [link] [comments]

    Looking for Tutor for x86 Assembly Language

    Posted: 03 Oct 2019 05:51 PM PDT

    Would anybody be available(maybe 1 or 2 times a week) to help me out with one of my college courses? The course is computer architecture and Assembly language. we focus on assembly for x86 processors. I'm really struggling and could use some extra help!

    Thank you!

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

    Just got promoted to junior software Developer with only an Associates.

    Posted: 03 Oct 2019 07:48 PM PDT

    So I have an Associates in comp prog. I was applying to all development jobs out of college but was getting hardly any responses. It was depressing af. I took a job as a tech support for a company, doing phone, email and chat support. I wrote a small tech support program that would help the support team be more efficient. I became friends with the developers and I think that helped me greatly with them recommending me to upper management. I was offered the junior software dev position after a year of tech support and a 10k raise. I honestly can't believe it, I start the new position on Monday.

    I'm just posting this cause I know there's a lot of people in my situation who are losing confidence in one day becoming a programmer. Especially those without a bachelors. Keep faith homies.

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

    Javascript Function (Money Service Tips)

    Posted: 03 Oct 2019 11:24 PM PDT

    Hi

    html file

    <div class='movingDiv' id='div1'> <b>Part 1: Calculating Meal Cost Conditionally</b> <br> What's your meal Cost? &nbsp;<input type ="text" id="box1"> <script type='text/javascript'> </script> <br> Would you like to tip? <input type="checkbox" id="myCheck"> <br> Please enter Tip Percentage (%): &nbsp;<input type ="text" id="box2"> <script> </script> <p id="output1">Display your cost here</p> <button onclick="calculateTip()">Click to calculate meal cost</button> 

    .js file

    function calculateTip() { let initialcost = +document.getElementById("box1").value; let tipPercent = +document.getElementById("box2").value; var tipped=(tipPercent+initialcost)*100; var withTipcost=(initialcost+tipped); var message1=('Your meal costs $'+withTipcost+' and the tip was $'+tipped+'<br/>'+'Thanks for your business.'); var message2=('Your meal costs $'+initialcost+'<br/>'+'Thanks for your business.') if (document.getElementById('myCheck').checked == true) { document.getElementById('output1').innerHTML= message1; } else { document.getElementById('output1').innerHTML= message2; }; 

    The var tipped=(tipPercent+initialcost)*100;

    is wrong I believe,

    when I input 10 dollars, and 10 percent tip, it outputs 110, But it should be eleven dollars. What's the formula for calculating the withTipcost?

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

    How to find all palindrome substrings given a string?

    Posted: 03 Oct 2019 11:18 PM PDT

    Given a string ababacba, how can I generate all possible palindrome substrings USING A TRIE?

    I was thinking of an approach of the following:

    1. Generate a suffix trie with the original string
    2. Reverse the string
    3. Generate all suffixes of the reversed string
    4. For each of this suffixes, compare by going each node in the suffix trie to determine palindrome

    However, it seems that this might not work for certain cases such as it detects babaas a palindrome when it is not, because reading ababacba is the same as reading ababacba, both bolded statement have abab and its reversed baba.

    Hence, I think this approach is not valid, so how can I generate all palindrome substrings using a trie?

    Desired output for string ababacba :

    ababa bab aba 
    submitted by /u/anoystud
    [link] [comments]

    Learning a programming language that does not need any kind of installment.

    Posted: 03 Oct 2019 07:22 PM PDT

    Hi guys, I am a complete beginner with regards to programming of any kind. Basically, my job has a lot of downtime, and I want to make use of that time to invest in myself. I decided to learn Java, but then I quickly found out that I needed administrator privileges to install anything in the company computer, which in truth was to be expected.

    I don't want to be deterred by this, and I still want to learn. I guess it doesn't have to be Java(which I am still determined to learn from home). Is there any programming language that I can learn that doesn't need anything but a browser? I am also open to just reading articles or lessons, but I also recognize that the best way to learn programming is to DO programming.

    Many thanks! Hopefully this will be the first of my many inquiries and questions!

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

    What's the minimum viable time/knowledge level required before landing a Junior Developer role?

    Posted: 03 Oct 2019 11:07 PM PDT

    Hi guys,

    I know it may be a strange question. But I just want to make sure I'm checking all the boxes while I search for my first job (front and backend web dev/web design/mobile development)

    • I have a GitHub and knowledge of git, which I contribute to almost daily or daily. Small stuff.

    • I'm working on my portfolio as I type this, have purchased a domain and I am capable of deploying a website no problem. I feel this is the main thing holding me back and so I should get it live ASAP to give an easy location where my work and skills can be shown off.

    • I have a basic to good understanding of HTML, CSS, JavaScript, how to manipulate the DOM, and some backend knowledge such as MongoDB, Node.js, and Express.

    • I have built a full stack application with user authentication and a nice UI, though it is not currently hosted anywhere (am going to deploy to GitHub pages today)

    • I'm now running through a Udemy course about modern JavaScript so I can get a better understanding of ES6 syntax, arrow functions, etc. I can use let and const in lieu of var with no problems, and understanding scope.

    • I've completed the first two FreeCodeCamp certifications (Responsive Web Design and JS Data Structures and Algorithms) which is supposed to equate to approx. 600 hours of self-study.

    • I have a very good understanding of Figma and basic design principles (I love Figma).

    ALL that being said, I don't feel I'm ready for a job yet. I've sent some applications through Glassdoor and LinkedIn, with no responses yet. But I feel a junior position would put me in a much better place to learn and allow me to grow my skill set way more than self-studying.

    Do I have imposter syndrome or am I really not ready yet? Is there any way to test this? Also, I'm just starting on a project which is my dream web app/mobile app, I've got all the features and functionality decided but just need to code it. I feel like I'm doing 4 things at once all the time, though, so it's hard to keep track of what I should be working on. Also, I work a full time job completely unrelated to computers and tech.

    I'm sorry for all the questions, but does anyone have any advice for me? I appreciate any help at all from fellow new programmers or seasoned vets. Also, sorry if I should have posted in the Web Dev subreddit but I felt I could get more straight answers here I guess?

    Tl:;dr- I don't know if I'm ready for a job yet, despite having most basic knowledge down for the jobs I see posted.

    Thanks in advance. J

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

    JavaScript Switch Function Not Outputing

    Posted: 03 Oct 2019 11:02 PM PDT

    Hi I need help, what's wrong with my function switch, and why is it not outputing

    My HTML file

     <br> <b>Part 2: Finding out the Day of the Week</b> <br> <p id="output2">Display the Day of the Week here</p> <script type="text/javascript"> </script> <button onclick="getWeekday()">Click to get the day of the Week</button> </div> </body> </html> 

    My.js file

    function getWeekday() { switch(new Date() .getDay()) { case 0: day=Monday break; case 1: day=Tuesday break; case 2: day=Wednesday break; case 3: day=Thursday break; case 4: day=Friday break; case 5: day=Saturday break; case 6: day=Sunday break; } document.getElementById('output2').innerHTML="The Day is " + day } 

    Errors:

    Uncaught ReferenceError: Friday is not defined

    at getWeekday (lab8.js:39)

    at HTMLButtonElement.onclick (lab8.html:52)

    Is there something wrong with my output? why is nothing hapenning when I click the button

    , and upon inspection it says "Uncaught refrence error" friday is not defined, and the HTMLbuttonElement.onlick is not defined???

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

    [C++] Getting a confusing linker error from the library I'm working on

    Posted: 03 Oct 2019 10:44 PM PDT

    I'm trying to make a small library to avoid having to rewrite functions all the time on a C++ course. I'm fairly new to C++, but have experience in Python and Rust.

    The errors I'm getting:

    LNK2019 - unresolved external symbol "class std::vector<double,class std::allocator<double> > __cdecl nonstd::get_n_input<double>(long,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??$get_n_input@N@nonstd@@YA?AV?$vector@NV?$allocator@N@std@@@std@@JV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) referenced in function _main LNK2019 - unresolved external symbol "double __cdecl nonstd::sum<class std::vector<double,class std::allocator<double> > >(class std::vector<double,class std::allocator<double> >)" (??$sum@V?$vector@NV?$allocator@N@std@@@std@@@nonstd@@YANV?$vector@NV?$allocator@N@std@@@std@@@Z) referenced in function _main 

    Library header (utility.h):

    #pragma once #include <string> #include <vector> namespace nonstd { // Get input of type T from the user n times, using a formatted std::string prompt. // Returns a vector of the given input type. // // Example: // auto foo = get_n_input<int>(3, "Number #{}: "); // // >>> Number #1: 3 // >>> Number #2: 7 // >>> Number #3: 12 // returns: std::vector<int> {3, 7, 12} template <typename T> std::vector<T> get_n_input(long n, std::string prompt); // Takes an iterable of values of type T::value_type that can be added together. // Returns the sum of the contents of the iterable. // // Example: // std::vector<int> foo = {1, 2, 3, 4}; // auto bar = sum(foo); // // returns: (int)10 template <typename T> typename T::value_type sum(T iterable); } 

    Library source (utility.cpp):

    #include <iostream> #include <string> #include <vector> #include "utility.h" namespace nonstd { template <typename T> std::vector<T> get_n_input(long n, std::string prompt) { /* Gets n inputs from the user; returns a std::vector of type T * * prompt is a formattable std::string, where '{}' is used as a * placeholder for the current counter value. */ std::vector<T> result; T input; long num_counter = 1L; std::vector<std::string> split_prompt = string_split(prompt, (std::string)"{}"); // This is defined in the file, but I excluded it here do { std::cout << split_prompt.front() << num_counter++ << split_prompt.back(); std::cin >> input; result.push_back(input); } while (num_counter <= n); return result; } template <typename T> typename T::value_type sum(T iterable) { /* Adds up the contents of any iterable type T, returns the sum of its contents * as type T::value_type. */ typename T::value_type result = {}; for (auto num : iterable) { result += num; } return result; } } 

    I can tell it's complaining about types, and it probably has to do with my templates, but that's as far as I can get. It's also worth mentioning that if I just copy-paste the function definitions to an executable source file, everything works like a charm.

    EDIT: Forgot #include "utility.h" when I cut the example down to essentials.

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

    Why is the bitwise logical operator XOR able to give us back the operand bits using the product ?

    Posted: 03 Oct 2019 10:37 PM PDT

    Hey guys sorry if the question is deformed. Basically I'm trying to understand with XOR how the product can be used again to help discover either one of the operands. The application of it makes sense, but I'm having trouble understanding fundamentally why it should work. I'm trying to equate it to something like if we have 7 + 5 = 12, and if we do 12-7 we can find the other operand to be 5, but I cant quite wrap my mind around it related to bit operations. Any help would be greatly appreciated

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

    How do you reset / restore Mac development environment? (npm, $PATH, brew, etc)

    Posted: 03 Oct 2019 10:13 PM PDT

    My environment is fuckered. After working on so many projects (electron, react native, npm, node, yarn, etc), and having to trouble shoot with so god damn many "fixes" to get things to work, my setup is unusable. Ive had to change $PATH, add extra lines to some "profile" file, uninstall, reinstall Node / NPM, install specific versions of electron, node-gyp, ETC. Now, normal things dont work (ie, I can npm i -g react-native-cli, and it says it installed successfully, but then I get " -bash: react-native: command not found" when I try to use it). How do I unfucker it? I want to restore it to brand new condition where I have to reinstall node, brew, yarn etc, and $PATH, permissions, whoami, etc is all back to like a fresh Mojave install. Is there a way to achieve this without literally deleting my drive and reinstalling Mojave?

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

    Help!! Submit button doesn't work

    Posted: 03 Oct 2019 10:10 PM PDT

    Hello everyone i know a bit about html i guess i would say i am an intermediate level html programmer (self taught)and i made a form and a submit button i am trying to get the site to submit the form to my email and I can't get it to do so here is my code i have am I doing anything wrong?

    <form class="form" action="mailto:XXXXX@yahoo.com" method=post>

    <input type=submit Value="submit">

    Maybe because it's not a "registered website" But i want to see if it actually works before i go through the process of making it an actual site Any help would be appreciated

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

    How would you swap the contents of two registers without using memory?

    Posted: 03 Oct 2019 09:37 AM PDT

    Suppose you have a theoretical processor with no memory and only two registers. You need to swap the contents between them. How would you do it in a programming environment? No restrictions on language.

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

    [.NET core, NUnit] Issue with getting tests to run in VS 2019

    Posted: 03 Oct 2019 10:05 PM PDT

    Hi everyone,

    I'm having an issue while learning TDD in .NET core, would anyone be able to tell me why these tests will not run? In my Test Explorer in VS 2019 the three tests are seen, but they just have an exclamation mark next to them saying test did not run. When I try to run just that selected test inside the test explorer, the output says ========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

    I am getting a unit test to pass though, but I dont think ive set up a unit test?

    I am learning TDD, so please be gentle lol

    Here is the code

    [TestFixture] public class CalculationTests { private readonly BabysittingDbContext _context; private readonly IConfiguration _configuration; public CalculationTests(BabysittingDbContext context, IConfiguration configuration) { _context = context; _configuration = configuration; } [TestCase] public void TestCalcFamA(Appointments newAppointment) { newAppointment.StartTime = TimeSpan.Parse("05:00:00"); newAppointment.EndTime = TimeSpan.Parse("12:00:00"); double TotalCost = 0; List<FamilyPayRates> familyAPayRates = _context.FamilyPayRates.Where(u => u.FamilyLetter == "A").ToList(); foreach (var timeframe in familyAPayRates) { if (newAppointment.StartTime >= timeframe.StartTime && newAppointment.StartTime < timeframe.EndTime) { TimeSpan timeSpan = timeframe.EndTime.Subtract(newAppointment.StartTime); TotalCost += Convert.ToInt32(timeSpan.TotalHours) * timeframe.PayRate; } else if (newAppointment.StartTime < timeframe.StartTime) { TimeSpan timeSpan = newAppointment.EndTime.Subtract(timeframe.StartTime); TotalCost += Convert.ToInt32(timeSpan.TotalHours) * timeframe.PayRate; } } Assert.That(TotalCost == 110); } [TestCase] public void TestCalcFamB(Appointments newAppointment) { newAppointment.StartTime =TimeSpan.Parse("05:00:00"); newAppointment.EndTime = TimeSpan.Parse("04:00:00"); double TotalCost = 0; List<FamilyPayRates> familyBPayRates = _context.FamilyPayRates.Where(u => u.FamilyLetter == "B").ToList(); foreach (var timeframe in familyBPayRates) { if (newAppointment.StartTime >= timeframe.StartTime && newAppointment.StartTime < timeframe.EndTime) { TimeSpan timeSpan = timeframe.EndTime.Subtract(newAppointment.StartTime); TotalCost += Convert.ToInt32(timeSpan.TotalHours) * timeframe.PayRate; } else if (newAppointment.StartTime < timeframe.StartTime && newAppointment.EndTime > timeframe.EndTime) { TimeSpan timeSpan = timeframe.EndTime.Subtract(timeframe.StartTime); TotalCost += Convert.ToInt32(timeSpan.TotalHours) * timeframe.PayRate; } else if (newAppointment.StartTime < timeframe.StartTime && newAppointment.EndTime <= timeframe.EndTime) { TimeSpan timeSpan = timeframe.EndTime.Subtract(timeframe.StartTime); TotalCost += Convert.ToInt32(timeSpan.TotalHours) * timeframe.PayRate; } else if (newAppointment.StartTime > timeframe.StartTime && newAppointment.EndTime <= timeframe.EndTime) { TimeSpan timeSpan = timeframe.EndTime.Subtract(newAppointment.StartTime); TotalCost += Convert.ToInt32(timeSpan.TotalHours) * timeframe.PayRate; } } Assert.That(TotalCost == 140); } [TestCase] public void TestCalcFamC(Appointments newAppointment) { newAppointment.StartTime = TimeSpan.Parse("07:00:00"); newAppointment.EndTime = TimeSpan.Parse("01:00:00"); double TotalCost = 0; List<FamilyPayRates> familyCPayRates = _context.FamilyPayRates.Where(u => u.FamilyLetter == "C").ToList(); foreach (var timeframe in familyCPayRates) { if (newAppointment.StartTime >= timeframe.StartTime && newAppointment.StartTime < timeframe.EndTime) { TimeSpan timeSpan = timeframe.EndTime.Subtract(newAppointment.StartTime); TotalCost += Convert.ToInt32(timeSpan.TotalHours) * timeframe.PayRate; } else if (newAppointment.StartTime < timeframe.StartTime) { TimeSpan timeSpan = newAppointment.EndTime.Subtract(timeframe.StartTime); TotalCost += Convert.ToInt32(timeSpan.TotalHours) * timeframe.PayRate; } } Assert.That(TotalCost==102); } } 
    submitted by /u/-whoKnowsMan-
    [link] [comments]

    How would I create a bash / shell script to perform this sudo code?

    Posted: 03 Oct 2019 09:46 PM PDT

    If grep does NOT find "item" in file Do this stuff Would this be close? if [ (grep item file) != 0 ] do this stuff 
    submitted by /u/DietDonut
    [link] [comments]

    [Java] What exactly is hashCode()?

    Posted: 03 Oct 2019 09:33 PM PDT

    I don't get it. Can someone eli5 it for me?

    Like I don't get what a "hash code value" is

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

    [C] Managing and allocating memory for large string arrays?

    Posted: 03 Oct 2019 09:03 AM PDT

    Howdy! I've been on an adventure into C (and later on C++) after years of working with Javascript/Typescript, Python, and C#.

    The two things that are driving me up the wall w/ C are strings and arrays (specifically ones containing strings).

    I have a program whose goal is to generate fake names, emails, and phone numbers (henceforth referred to as 'people') and then append them to a CSV file. The program, when opened, takes in command line input to indicate how many fake 'people' we want to make, e.g., `main 5` will create 5 'people'.

    Everything is fine and dandy, until I attempt to stress test the program. 5 'people' works, 10 'people' works, 15, 20, 50, 75, 100, 150, but... the second I attempt to create, say ,200 or more 'people', it seems like my memory allocation falls short. That is, only the first bunch of 'people' are added to the csv, and I end up 25-50 'people' short.

    My question is: how do I properly and accurately allocate memory for arrays of any length?

    Here is the repo I'm using to store the code. Feel free to offer general suggestions as well. The Python world coddled me a little bit, it seems, so any criticism is helpful. Thanks!

    EDIT:

    Thanks to everyone's help! I was romanticized, so to speak, but arrays / structs in C and wanted to get more comfy with them. However, that affected the outcome of the program. Thanks to the advice here, I altered my randomInteger calls so that outOfBound array errors do not occur, and I also started writing the strings directly to the csv file.

    Here is the finished code:
    https://gist.github.com/MochaMethod/f1f4872016eb33ba11f75ad30ea82e35

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

    No comments:

    Post a Comment