instruction
stringlengths
71
95.1k
Challenge: Given 2 lists of positive integers. Write a program which multiplies corresponding elements in these lists Specifications: Your program should accept as its first argument a path to a filename. The lists are separated with pipe char: '|' . Numbers are separated with a space char. The number of ele...
I'm fairly new to MySQLi and PHP, but I've been working at it for a bit now, and reading up on how to make secure login forms, avoid SQL injection etc. I'm a mere amateur though. I've created an index.html page (not including the code here, just a basic form though), a register.html page (not including the code here, a...
For Prof. Yorgey's 2013 Haskell course, I'm working on a homework to simulate a Risk battle. type Army = Int data Battlefield = Battlefield { attackers :: Army, defenders :: Army } deriving (Show, Eq) In addition, Prof. Yorgey implement the following code to simulate the random throwing of dice: ...
This is the problem statement for Lonely Integer. There are N integers in an array A. All but one integer occur in pairs. Your task is to find out the number that occurs only once. Input Format The first line of the input contains an integer N indicating number of integers. The next line contains N space separa...
While reviewing Multiplying Lists, I got the impression that the problem was naturally suited to Java 8 streams. Unfortunately, since there is no convenient way to zip two streams, the solution ended up being uglier than I expected. The task is to take lines of input, in the form a0 a1 a2 … an | b0 b1 b2 … bn, where t...
I'm trying to get table header name in excel. I tried it using index, IF and MATCH. It works but I am not sure whether my formula is the best or not. This is how my sheet looks: And here is my formula to get produk name (E19:E22): =INDEX( $C$10:$H$10,0, IF(IFERROR(MATCH(D19,$C$12:$C$14,0),0),1, IF(IFERR...
This takes a dataframe as an argument, looks at all pairs of two columns in that data frame (country and year) and returns a column value of that pair in another data frame (the gini number). get_gini <- function(year, country){ GINI = 0 SUBSETTED_WITH_COUNTRY_NAME_NOW_WITH_YEAR <- inequality[inequality$Code== ...
This was done as an assignment in school. As I am still learning some of the basic parts of Java be merciless when it comes to my code. As it is an assignment, some things are unchangeable. The specification requires: Swing. So no third-party library is allowed. Cell class with getCol() and getRow() methods. For the f...
I've started learning C++ recently and want from what I've gathered smart pointers are the way to go when storing stuff on the free store. I want to make sure I've got the basic hang of C++(11) correctly. I've implemented a very basic vector class (a mathematical vector) and would greatly appreciate if anyone would poi...
I'm trying to learn some OOP programming using Java, so I've created TicTacToe. Could you give me some advice on how I can improve this code? Player.java: package com.kamil.dude.tactoe; import java.util.Random; import java.util.Scanner; public class Player { public char currentPlayer; public Player() { Random ge...
I coded this program as a challenge for /r/dailyprogrammer. Basically this program can convert any number from any base to another base including negative bases as long as the input is coherent. Did I follow the Python 3 standard or commit any obvious mistakes? I am also wondering if I can efficiently filter out nonsen...
I have set up card, deck, hand, player, dealer, and game classes. The game class is there to keep a lot of the logic out of the interface (main.py). Let me know any thoughts on that. I haven't ran pyflakes or a PEP8 checker on it yet, so keep that in mind! main.py from game import Game from card import Card from deck i...
I'm dealing with data that stores its state as a String, treating the string like a stack. I also have to combine that with error handling. To that end, I'm using the type StateT String Maybe a. I have a function to pop and to push a Char from and to the string: pop :: StateT String Maybe Char pop = do x:xs <- get ...
I'm starting to learn OOP with PHP, and all I've learned so far is just by searching and reading. So I have this need to check input data for certain things like min of chars, max of chars, spaced or not spaced, just letters or not. So far I've just created the alpha() method which is just for letters only. I'm pretty ...
I was trying to solve a problem which needed you to count the number of perfect squares in the given range: #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int isPerfectSquare(int x) { float s = sqrt(x); if (fmod(s,1) ==0) return 1; else return 0; } int main() { ...
I am about a month into learning Java and I'm just looking for some comments on my code. Specifically, I would like to know if I'm being as efficient as I can be. This is the most complex thing I've come up with so far (that works) and I wanted some feedback on my developing coding style. public static void main(Stri...
Is it possible to make the hexStr function faster? #include <sstream> #include <iomanip> #include <stdio.h> std::string hexStr(unsigned char* data, int len) { std::stringstream ss; ss << std::hex; for(int i=0;i<len;++i) ss << std::setw(2) << std::setfill('0') << (int)data[i]; return ss.str(); }...
This is my first program using classes. How could this be improved? #include <iostream> class TicTacToe { char m_field[3][3]; char sign; public: char Sign(char x) {sign=x;}; void MakeField(); void DrawField(); bool IsFree(int y, int x); bool FindAndReplace(int x,int y); bool Row(); ...
This is the follow up version of a previous question on combining different categories and their properties. The home page contains the overarching company information. The product page contains product information and links to the home page. I do not get any error messages in Google testing tool. But I feel that the c...
I wrote this code for Android server interaction. The way I built the client was an onSharePreference of strings includes photo encoded to a base64 String object {imei, barcode0, barcode1, photo0, photo1, time_taken0, time_taken1,..} because I had the possibility the user won't be connected to the internet all the time...
I know I can increase the size of the heap but that seems like a poor solution. This program runs correctly on small files but when run on large data sets it crashes with the OutOfMemory: Java heap space error. This code executes multiple hash map operations and I'm certain that the haphazard way in which I strung the...
I want to upload images to server from browser window. I'm using this function for image upload. Images are uploaded by GD library. What is your opinion of this code? Is there still a way to upload a malicious file? <?php function imageUpload($name, $thumb = false, $max_size = 5242880, $height = null, $width = null, $T...
I am trying to learn how branch optimization works. For an experiment, I have a recursive fractal terrain generation and I have moved all if statements to binary tables (don't know the words, will comment in code). Is doing what I have done in the code better than using if's, it runs about 15% faster. Is there a better...
I am new to Python and am trying to see if there is a cleaner way to write my code. The following code take iterables as parameter it produces the first value from the first parameter, then the first value from the the second parameter, ..., then the first value from the last parameter; then the second value from the f...
I am developing a chat program (mountreus-chat and GitHub) in Node.js using Socket.io and my code looks awful. I'm starting to use commands and now it's even worse. Here's a code snippet (you can find every detail on the Github repo): io.on('connection', function(socket){ if(socketConnections().length <= 1024){ ...
The main purpose of my program is to extract GPS information from text messages sent to several GSM modems send from various GPS tracking devices. The main flow of my program loops in three steps: Receive SMS message (with the help of SMSlib) Extract data with regex Push data to MySQL database I've only been exposed ...
I know I should use services and patterns to refactor this controller action, but I can't imagine one that could fit/be appropriate for this problem. It seems a strategy or template, but a strategy is supposed to be changed if needed; in my case, it should be always the same: Get the customer If doesn't exist store t...
Here is one of my msTest Unit Tests and possibly one of the worst "looking" tests. [TestMethod] public void UniquePositionPoint_CreateUPP_UPPExistsInPPField() { //Setup the values to be used by this test. CIM_Network network = new CIM_Network(); string x = "5"; string y = "10"; string expectedMRID ...
I have developed a readline function in C and I want to know your opinion on it: // read a the whole line, stop if encouter eof static char *readline(FILE *in, sid_error *error) { #define MAX_SIZE 64 size_t size = MAX_SIZE; char *str; if((str = malloc(sizeof *str * size)) == NULL) { *erro...
I want to simplify my Rails models, current looks like this: class User < ActiveRecord::Base has_many :offers, dependent: :destroy has_many :reviews, dependent: :destroy has_many :comments, dependent: :destroy end class Offer < ActiveRecord::Base belongs_to :user has_many :documents, as: :documentable has_...
I wrote this DFS in Python and I was wondering if it correct. Somehow it seems too simple to me. Each node is a class with attributes: visited: Boolean sons: list of nodes linked to the current node. This code should work both for directed and undirected graphs. def DFS(node): node.visited = True if node ==...
Building on my ANTLR tree listener, I'm now starting to see how the whole thing is coming together. As I proceed to implement the numerous Node classes I'm going to need to make sense out of the ANTLR parse tree, I feel like I'm doing more and more weird things.. oh, the tests pass. But the implementations... here, hav...
I decided to implement most of the reddit Daily Programmer space probe challenge. My program creates a 2D space that have asteroids and gravity wells distributed (the percentage of gravity wells and asteroids is given to the SpaceProbeModel class which randomly distributes them) and finds the shortest path from a start...
I wrote a solution for a jug problem (given two jugs of water of different sizes find the steps needed to get specific amount of water in one of the jugs). I'm hoping for some input on my code. How can I make it better? More readable? Optional - Is there a faster or more efficient solution I should look into? #!/usr/bi...
What is the quality of the code I've written? Is it easy to read or is it a low-quality piece of code? Also, is there any way I can improve the algorithm itself (beside changing C parameters)? using System; using System.Threading; using Un4seen.Bass; using Un4seen.BassWasapi; namespace Szab.BeatDetector { public enum ...
I just finished a fairly easy homework assignment. Basically all I had to do was add six JPanels that were just text boxes with color names as the text. However, the color of the font had to match the text, so for instance, black had to be black, blue had to be blue, etc. It works find but it just seems like I could ...
I have a Back function, and it is growing. I also think this is terrible, but I don't seem to get how it can be improved: public void GoBack() { NavButtonUsed = true; Forward.Insert(0, Back[0]); Back.RemoveAt(0); if (Back[0].Title.StartsWith(" ") && CurrentItem.Menu != Back[0].Menu) { swi...
I am building my "base exception to end all base exceptions" class in C# and was looking for some opinions on my implementations so far. Ideally my usage of integrated Rethrow, Throw, and ThrowFatal methods for some syntactic sugar. using System; using System.Collections; using System.Collections.Generic; using System....
The following is my sample code: String month = "09"; String year = "2014"; String monthYear = "092014"; The monthYear format is MMyyyy, I wish to format it to become MMyy. Thus, I am doing it as follows: Method 1: final SimpleDateFormat oriMonthYear = new SimpleDateFormat( "MMyyyy" ); final SimpleDateFormat changeM...
I've built a modal window as seen in my modal HTML and CSS code below and was looking for any tips/advice regarding how well I've applied any best practices in both my HTML and styling with regards to building a modal window. Here's the tutorial I followed. Here's my modal HTML code: <div class="modal fade" id="basicMo...
I have a web application to manage computers. Every registered computer is locally querying the latest information and updates the database with it in a 10 minute cycle. But the computer is only allowed to update its information and nothing else. Currently I'm identifying the computer like this: I get its hostname from...
I wrote this code in C++ to convert an array to a binary tree. For instance, int nums[] = {7,5,9,1,7,3} to a binary tree (root-7, root's left child-5, root's right child-9...). ( here, I made a function named 'create_tree()' which only take one argument ) Is there any shorter way to do this? #include <iostream> #includ...
I'm a relatively new (~6 mos) developer, and I'm hoping for some feedback on my code style/structure. While I'm particularly interested in efficiency and maintainability, I'm open to feedback regarding anything that comes to mind from more experienced developers. /** * Attempts to create new SavedSearch (eventual POST...
How can I speed up my app? It's very slow if I click on a button and open a new page. All data in time is local. I'm not sure if the problem is in my code or xamarinu. foreach (var category in avm.Categories) { ToolbarItem ItemCategory = new ToolbarItem(); ItemCategory.Name = category.Name; ...
To get a simple, responsive, 4-directional movement in a 2D game, I've implemented the following. When a key is pressed, the add method adds the direction to the keys array. When the key is released, the remove method removes the direction from the keys array. In my Update method, I call getLast to get the last directi...
Introduction I've written a simple command line todo-list in Haskell. The full code can be found here. However, given people's time constraints, I have selected three verbose functions for review. Function One program :: StateT TodoList IO () program = do StateT $ \xs -> do (choice,_) <- runStateT requestCh...
In my application I need some resources to be loaded and I have services to load each of them and then I need some point to know that all requests finished. First thought was to use $q.all with array of promises from that services. But it would be resolved only if all promises resolved which is now always the right cas...
I made an admin login script for my own CMS website that I'm making in Code Igniter 2.2.1 and I'd like to know what are the potential threats or some holes that I might have left open. This is how it goes: user submits form to admin_login page where the script collects the post data the script checks if the admin use...
When integration testing Rails applications HTTP request helpers can take a string or a named route as the first argument. I find myself writing: test "user visits edit page" do homer = users(:homer) get "users/#{homer.id}/edit" assert_response :success end But I can also write: test "user visits edit page" do ...
I have this script for creating SQLite backups, and I was wondering whether you'd have any suggestions on how to improve this. I was thinking that maybe it should create the backup dir if it doesn't exist, but not sure if it's necessarily better. Besides functionality/performance tips, any styling/formatting tips are a...
I find that I often want to calculate summary statistics from collections of data and decided to create a template to do that. I'm interested in a general review, but I also have some specific questions. Is the use of the lambda "too clever?" Is std::accumulate OK? Specifically, I'm thinking of the potential for ove...
Below I have code that calculates epoch seconds. It is built to try to change run time checks into asserts in order to give performance in production. I want to make sure all the edge cases are correct, though. #define DAYSPERWEEK (7) #define DAYSPER...
I am going to use the following class which is very simple to use and get user info in pages: <?php ini_set("display_errors", "on"); class LoginSystem { /* Start Config */ private $dbhost = "localhost"; // Host Name private $dbport = "8889"; //Port private $dbuser = "root"; // MySQL Database Username ...
I am working on a small app to help my kids study their multiplication and addition. And I have various preferences I want to be persisted between visits. What do you think of the below to get the settings out of local storage? I know I could do it even more simply by simply stringifying the whole object at once, bu...
In preparing a solution for the CodeChef "Will India Win" challenge, I am trying to find out the xor of list of numbers. The first line of input contains the number of test cases, 1 ≤ T ≤ 106. Subsequent lines contain fifteen space-delimited numbers (each between 1 and 231), to be XORed together. def main(): t = in...
I wrote a tool to store text as colors in a image around the border. I then saved the resulting image to file. To use the resulting file I set it's path to a the src attribute of a tag and call DrawImage and colorToText OnLoad to read the contents and remove the messy data around the edges of the image, thereby presen...
I'm a bit lost with implementing MCV pattern on javascript. Where should events (such as 'click','change') come in on MVC in javascript? I have this event function, var EventExample = function (controller, view) { this.controller = controller; this.view = view; return this; }; EventExamp...
What do you think? In particular, I'm not sure about my exception handling approach to raise errors when posting objects; but I couldn't come up with anything better. public class Thing { public Thing(int number) { Number = number; } public int Number { get; set; } } class Program { stati...
I have written this code base on AsciiEngine. How can I improve this code? #include <iostream> #include <fstream> #include <vector> #include <string> #include <memory> #include <algorithm> #include <unordered_map> #include <type_traits> #include <random> #include <chrono> #include <cassert> #include <Windows.h> enum ...
I would appreciate any opinions and critiques anyone has on my code. My code allow you to read a ini file. parser.c #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include "parser.h" // read a the whole line, stop if encouter eof static char *readline(FILE *in, sip_error *error) { ...
I have recently made two kinds of linked lists in Java. I know that there is one with generic and one without. However, what I am really concerned about is which style should be used mostly (or which style should be used as the main style to implement the LinkedList structure). When talking about these two styles, coul...
Ultimately, my goal is to take two lists and then generate a third consisting of items that the first two lists do NOT share. I am able to get the results I want using two foreach loops, but I am hoping to learn about some magical List tool that will do it more cleanly. public List<string> removeMatchingItems(List<stri...
I'm trying to implement a mathematical expression evaluator and equation solver, and based on extensive online research and my own experimentation have come to the conclusion that the best way of writing one is by first parsing the expression and breaking it down and then feeding it into an evaluator/parser. Note I wan...
I've never written on VKScript (and on Javascript). I need high performance code to get more friend lists faster. var targets = Args.t; // get params (ids) // prepare all variables before loop var all_friends = {}; var req; var parametr = ""; var start = 0; var q = {}; var user_friends = {}; // get each target from al...
I rarely program C++ in anger, and considered myself somewhat rusty, and certainly not up to speed on C++11. For a bit of exercise, I thought I'd try implementing sha1sum, as wasn't really up to speed with topics such as cryptographic hash functions either. (Yes, yes, you shouldn't use SHA-1 in new code, understood!). ...
This code goes to the website containing the PDF, downloads the PDF, then it converts this PDF to text. Finally, it reads this whole file (Over 5000 lines) into a list, line by line, and searches for my name in it. import mechanize import os br = mechanize.Browser() br.open("http://sttm.org/Bulletin/Bulletins2015/tabid...
I came up with an idea for a userscript to simplify writing answers on Stack Exchange while writing a previous answer. This userscript adds "Review"-links on the top of each code segment. When clicked, it adds checkboxes in front of every code line. You select the checkboxes for the lines you want to comment about, cli...
Now I'm reading C Premier Plus by Stephen Prata and there's an exercise 4 in chapter 6 which has no solution in the book, so I can't check if I did it properly. My code works like it should, but I want to know maybe there are some better or cleaner solutions. Here's the description: Have a program request the user to ...
I am looking to create a simple column based responsive framework, and would like to call my classes something like: <div class="col col-4-2-1"></div> where the div would display as 4 columns on a desktop browser, 2 columns on a tablet and one column on a phone (these breakpoints are hypothetical). or <div class="col...
I have a dict of stock tickers (KEY) and a data point (VALUE; e.g. dividend yield). I want to know which tickers have a value between a specified min and max value. Given data = {'KO': 1, 'WMT': 0, 'IBM': 3, 'PG': 2} gte = 1 lte = 2 Func1 def func1(data, gte=None, lte=None): data_set = set(data) gte_set = set(...
This is fairly simple, so I'm just looking for ideas on anything that can be cleaned up, places it can be extended, and suggestions regarding style/naming (I'm terrible at naming). It allows you to write something like: object TimerTest extends App { import Timers._ val time: Long = TimeBlock { timer =...
I finished my Blackjack OO game and I'd like to get my OO skills reviewed. #include <iostream> #include <vector> #include <algorithm> #include <ctime> #include <string> class Card { private: char m_card; // 'A' ,'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q' int m_value, //...
After much trial and error, I finally came up with this code to call on other classes to perform their function. This code works and does what I want it to do, so I am looking for some comments on the code efficiency. What I want to happen is have the user input which calculator they would like to use and have that ca...
I wrote a parser for the IRC RFC 2812 spec and would like input on my use of the strategy pattern for this. I created an IrcMessage class that is responsible for taking the server response string from the (examples below) and parsing it. The server response format is: :<Prefix> <Command> <Space Separated Args> :Optiona...
This is a coupon collector code to analyze the running time. I need some suggestions on improving the running times of this code. I have used the data structure dictionary, but is there any other data structure that will perform faster? import random import numpy as np import matplotlib.pyplot as plt from array import...
In GUI that provided with the right username and password lets you open up an address book like GUI where you have crud like operations. I'm still very inexperienced with swing facilities especially with layout managers and placing my components on a panel/frame. I'd like some feedback about how to properly structure t...
I was hoping to receive some criticism on this block of code. I wrote it to write the contents of a dictionary to excel range in VSTO. It works well. I am interested to see how people could improve it. What would you do differently to make it more expressive, efficient? public static void WriteToRange(this Dictionary<...
I am trying to send daily mail alert to users based on some timer values. For that I've used Addhandler to call the sendmail() function on timer Tick. In this scenario I faced a problem and I am unable to pass arguments to the function through AddressOf. What I wanted was to use my function, which took these parameters...
I changed my mind. I don't want to implement 200-some Node classes. Instead, I'll be working directly with the ANTLR generated classes, to implement the Rubberduck code inspections, unit test method discovery, the "Code Explorer" tree view, and everything else Rubberduck might need a parse tree for. The Node derived cl...
I created my first java game in LibGDX and it's working fine but I'm 100% sure a lot of my code can be written shorter than now. Does anyone have tips how I can make this code better? Like the Gdx.input.getX(), if I run this on Android, it's fine, but when I run this on PC, you just have to hover over your screen to ch...
I have reimplemented the quicksort algorithms that takes a list and sorts it in non-decreasing order: void qsort(int* l, int len) { if(len <= 1) return; int pivot=0; for(int i = 0; i<len; i++) { if(l[i]<l[pivot]) { swap(l+i, l+pivot...
This is a follow up to: Validating individual properties and whole items I have a custom class I've written which allows me to validate individual properties of items, without firing validation errors on other properties. This allows me to individually validate what my users are editing without flinging up a lot...
I use Project Euler to teach me programming and not to submit any results. As such I look up the expected return values to double check my solutions. To organise my files I use the following folder structure: main.py \euler # The problem files __init__.py # empty e001.py e002.py ... \input # Additi...
I have the following function: def save_to_file(data, columns_order, save_filename): """ Saves data to file :param data: data to be saved :param columns_order: the order of columns if needed to rearrange else put "" :param save_filename: the filename (...
I'm working off a specification that says a bunch of fields within a record (one record being one line) must be blank. For example, it says that chars 6-14 must be blank. I am building a class hierarchy structure that represents the layout of the file, and within this class hierarchy I'm including every field for each ...
I wrote a function to get a 2-digit random number for each day, but it should be retrievable. For example, today's random number is 72, but later I can provide "day and month" and get this 72 again. function ranDay($day,$month){ $pow1 = round(pow($day,$day))*$month; $pow2 = round(pow($day,$day))+$month; ...
Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of the front: frontTimes("Chocolate", 2) → "ChoCho" frontTimes("Chocolate", 3) → "ChoChoCho" frontTimes("Abc", 3) → "AbcAbcAbc" frontTimes("X",...
I'm still working on a parser that can parse log entries from a game called HearthStone, the overall idea is that it will read the log file live when the game is running, parses the log file and show interesting and useful data in real time. For the question the focus is on the API I have created to parse log entries. ...
I found this question in an old exam in computer science. I solved it in a good way, but I'm not convinced that my solution is the best solution. I believe that there's a better way to solve it. Given N Columns that are lined up, The horizontal distance between two adjacent columns (The lower edges) is exactly 1 met...
I recently came to write a regex to parse URLs. Now I wonder, did I miss something? Did I make a mistake or could I have written it cleaner? That's why I'm here. In order to write the regex, I took this paper as a reference (together with some Wikipedia articles about URIs/URLs). //According to http://www.ietf.org/rfc...
I've been working on implementing Google Code Prettify and finally got it to work correctly. You can see my test file here to see what it looks like. I worked from a template and tried to improve it. There is a lot of HTML boilerplate code that apparently is needed (mostly JavaScript links). I tried to remove some of t...
I'm not sure if this site has the right audience for anyone to be able to respond to this, but I wrote a header only scheduler which schedules a task to be run in the future on another thread: #pragma once #include <thread> #include <mutex> #include <condition_variable> #include <future> #include <functional> #include ...
I am new to this Immutability concept and I have some coding experience in JAVA. Recently as a part of internship program, they gave me a 5-day task, which was to implement Immutable Queue. After some research I came with a solution which was given below. Can some review the code. [Technically your are not helping me i...
Here is a pure Python script that saves an HTML page without CSS but with all images on it and replaces all hrefs with a path of an image on the hard drive. I know that there are great libraries like BeautifulSoup and others but I would like to try myself with pure Python. Actually there is no practical usage of this s...
I have a record type which holds a list of table rows. Each row is also a list. The first row is assumed to be the header row. In addition the type optionally defines a filter - a list of columns (the actual string value of the column header). Then the type have a member property FilteredRows. If no filter is defined, ...
Resurrecting my C++ saga, I was given this project for my CS2 class: This problem considers several ways to compute \$ x^n \$ for some \$ n \ge 0 \$. Write an iterative function power1 to compute \$ x^n \$. Write a recursive function power2 to compute \$ x^n \$ using the following recursive definition: $$ x^n...
I have the following code, though I'm not sure it is efficient as it could be. $(window).scroll(function() { var scrollT = $(document).scrollTop(); if (scrollT >= 180) { $("#primary-nav-wrapper").addClass("scroll"); $("#primary-nav-wrapper li.front").addClass("active"); $("#primary-na...
I made a simple C++ snake game, and I want some advice from you: what is good, what I have to improve. One main problem is that flipping (which you'll notice if you play it). #include <conio.h> #include <ctime> #include <iostream> #include "windows.h" const int width = 60; const int height = 15; double diff=0.5; clas...
I am working an a more meaningful way to print objects in VBA. The desired result should look something like this. Console.PrintLine List.Create(1, 2, 3) List(1, 2, 3) The concept is that objects implementing an IPrintable interface are printed as their ToString property. Primitive data types are printed as is Conso...
I wrote this function for my next learning project (cfg parser). What do you think about it? char readline(FILE *fp, char **line, size_t *size) { *size = 0; size_t cpos = ftell(fp); int c; while ((c = fgetc(fp)) != '\n' && c != EOF) (*size)++; if (*size == 0 && c == EOF) { *line = NULL; ...