Add this tag to your question to indicate that you are new to the language of your code. This will often be taken in to consideration by reviewers when assessing your code.
4
votes
2answers
76 views
Writing strcat (string concatenate) in C
char *cat_string(char *to_cat, char *destination) {
char *copy = destination;
while (*copy != '\0') {
*copy++;
}
while (*to_cat != '\0') {
*copy++ = *to_cat++;
}
*copy = '\0';
...
3
votes
0answers
21 views
Finding the next higher digital permutation of a number
This is my solution for CodeEval challenge 44.
The function followingInteger takes a number in its decimal representation and returns the next higher permutation of the digits of the number. If there ...
6
votes
3answers
71 views
JS validation and submission with AJAX
I've got an assignment to do pure JS validation as well as submit with AJAX. Here is the code I've got so far. I'm wondering if I can do away with the whole "reason" bit. That was because it was ...
-2
votes
1answer
29 views
pdo variable in select query [on hold]
i try change mysql code to pdo
and make this codes:
<?php
$jds="SELECT tc,tn,tb,tfz,tmz FROM teams WHERE leag='$lig' ORDER BY tmz DESC, tfz DESC, tzade DESC LIMIT 18";
$sth = ...
7
votes
1answer
45 views
Download a file and update the current downloaded percentage
I am not a big fan of JS, but have been forced to use it in this situation for various reasons.
My task: Download a URL to a target file, and update another part of the application with the current ...
17
votes
8answers
3k views
Feedback on a programming practice problem in C
This is a programming practice that our teacher gave us, and I would appreciate if someone can look over my program and tell me if I did a good job.
Basically, the context is I joined a company and ...
11
votes
3answers
721 views
Find longest sequence horizontally, vertically or diagonally in Connect Four game
I'm new to programming and also to Java and working on problems in Intro to Java by Robert Sedgewick. Here is my question:
Connect Four: Given an N-by-N grid with each cell either occupied by
...
9
votes
6answers
596 views
Small one time pad encryption program
This one time pad encryption program I have written (basically just an XOR "encryption" program) seems to be working fine, compiling nicely (gcc -o ./OTP.c), and doing what it's supposed to. However I ...
6
votes
3answers
107 views
Factory for classes unknown at compile time
I have a class called Machine. It contains a list of parts and a list of actions. The list of parts will contain instances of the Part class subclasses and the list of actions will contain instances ...
5
votes
1answer
66 views
GIF to HTML5 video conversion
I'm still at a very beginner level and I'm constantly working on small things to try and develop my skills. I'm hoping someone could just give me a quick review if there's anything obviously horrible ...
6
votes
2answers
105 views
Console-based menu system
Recently I started learning programming and I created this program. I've added something to it with every new lesson.
How is my code-writing? Do I make mistakes I shouldn't make?
The program itself
...
5
votes
1answer
60 views
What are your opinions on these small scripts?
I am new to JavaScript, and I was wondering if anyone can share their opinions on what I have done below:
First of all, the following functions are all placed in a file called main.js and that file ...
9
votes
4answers
703 views
Human class implementation
I just want an indication as to whether or not I'm on the right track regarding PHP OOP, at least on a basic level. Positive criticism welcome.
P.S. Excuse the visuals of the code. This is how I ...
4
votes
1answer
44 views
Writting day_of_month and month_day with pointers instead of array indexing
Rewrite the routines day_of_year and month_day with pointers instead of indexing.
The exercise is quite simple, this is the solution:
int day_of_year(unsigned int year, int month, int day) {
...
8
votes
1answer
57 views
Help speeding up my first Bash script
This is my first more-than-1-line script. It takes an inputfolder and a file prefix and get all the files matching. For the first of the files, the script grabs the first line and appends an extra ...
5
votes
1answer
62 views
Python script using distutils to copy files on a Mac
I have a Python script I have written to copy files to a mounted Windows SMB share on a Mac.
import os
import distutils.core
# Create a local site for the mount to reside
directory = ...
6
votes
2answers
181 views
Read an input text file and store the tokens in 2 different arrays
I am very new to Java so please ignore if there are obvious mistakes. If my question seems redundant then please guide me towards the correct link. However, I have surfed enough in order to find the ...
1
vote
1answer
32 views
Interactive menu system in Bash [closed]
This is a simple loop menu script that I have for class. The goal was to make a menu with applicable commands.
Menu:
A. Greet me. (Greet the user by their username (using the whoami ...
5
votes
1answer
65 views
Best Practices concerning Includes and SQL Connect Strings
I'm just starting to learn PHP. I have three random questions about PHP and one question about Code Review. None of them are technical questions ("will this work?"); they're best practices questions ...
6
votes
1answer
41 views
Functions that converts day of year to month and day and reverse with error checking
There is no error checking in day_of_year or month_day. remedy this defect.
Here is the solution:
int day_of_year(unsigned int year, unsigned int month, int day) {
int leap, i;
leap = ...
7
votes
1answer
57 views
Storing lines in an array
Rewrite readlines to store lines in an array supplied by main, rather than calling alloc() to maintain storage. How much faster is the program?
Here is my solution:
int readlines(char **lineptr, ...
8
votes
2answers
67 views
Member list reveals member information on click (#1)
What I'm doing?
I'm creating a member-list where initially only the names are visible. Clicking the names reveals the member information. This is done with jQuery by adding/removing classes.
I left ...
4
votes
2answers
85 views
Arduino based ultrasonic sensor program, output HIGH to control electric motor
I am brand new to C++ and am working with the Arduino micro controller. The project I've been working on for my university requires me to write code to do the following:
If the ultrasonic ...
8
votes
1answer
198 views
PHP form review
I saw somewhere on here that it helps reduce spam by adding a dummy input field that you hide with display: none, and like if it's filled out, then it's obviously a bot sending the message. Well, I ...
4
votes
0answers
41 views
Script which migrates files to secondary storage and symlinks them
I wrote this code to clean up some of the space on our file server. We've got 15 years of legacy data that nobody accesses or changes or cares about that we have to keep regardless. I'd rather have it ...
7
votes
1answer
77 views
Java Calculator
I tried to make a calculator in Java and have added some stuff. I'm a beginner and have learned yesterday how to make buttons.
import java.awt.Dimension;
import javax.swing.*;
import ...
3
votes
1answer
64 views
Script for generating a report in Google-Spreadsheets. Looks for various values to check and count
It all works exactly as it should. It finds data from today, finds unique emails and puts them in an array. I then check the data again from today, against the emails to total up different values. ...
2
votes
2answers
60 views
Merge Sort Algorithm in Python
Implementing basic sorting algorithms to learn them, and coding, better. Criticisms/ critiques welcome. Also possible optimizations.
import unittest
import random
def merge_sort(seq):
"""Accepts ...
2
votes
1answer
39 views
Pointer version of itoa
Rewrite appropiate programs from earlier chapters and exercises with pointers instead of array indexing. Good posibilities include getline(Chapter 1 and 4), atoi, itoa, and their variants(Chapters ...
15
votes
5answers
1k views
Basic Java dice game
public class diceGame {
public static void main(String[] args) {
int dice1;
int dice2;
int count = 0;
int theSum = 0;
int lowest = Integer.MAX_VALUE;
...
1
vote
0answers
37 views
Simple Hexadecimal code to Seven Segment display [closed]
I'm currently learning VHDL and it is honestly a headache when it comes to getting it to compile. I've tried to get it to be as painless a process as possible, but the instruction from my professor is ...
4
votes
1answer
53 views
How to make this lingo game more compact?
I made a lingo game using Python:
You guess a word, and if its letter(s) is in the same spot as a hidden word's, you add [] around the letter. If it's in the hidden word, but not in the same spot, ...
4
votes
2answers
89 views
Insertion Sort Algorithm in Python
Implementing basic sorting algorithms to learn them, and coding, better. Criticisms/ critiques welcome. Also possible optimizations.
import unittest
import random
def insertion_sort(seq):
...
5
votes
2answers
154 views
Finding the most common character in a string
I have started to try and work out the TopCoder problems. The "StringDup" problem asks us to:
Create a class called StringDup. Given a string made up of ONLY letters and
digits, determine which ...
7
votes
1answer
60 views
implementations of strncmp, strncat, strncpy
Write versions of the library functions strncpy, strncat and strncmp, which operate on the most n charachters of their argumen strings. For example, strncpy(s, t, n) copies at most n charachters of ...
3
votes
1answer
55 views
HTML and CSS markup to achieve desired result
I am new to HTML and CSS. I was wondering if anyone could give me some advice on my use of markup and CSS to achieve this result. I am trying to get a fixed full height sidebar with a list with sprite ...
10
votes
2answers
141 views
Review structure of PHP/HTML
I am very new to PHP and I kind of sort of want to create the pages like I would in ASP.NET; it's just the way I am wired. I have been inserting the header/menu using a PHP Include and here is what ...
9
votes
2answers
104 views
strend, function that checks the occurence of a pattern at the end of a string
Write a function strend(s, t) which returns 1 if the string t occurs at the end of s, and 0 otherwise.
Here is my solution:
unsigned int strend(char *source, char *pattern) {
char *saver = ...
8
votes
2answers
129 views
Search for directories with a certain prefix that contain no files of a given type
These two functions search for directories with a certain prefix that contain no files of a given type.
Does the code adhere to Ruby standards and conventions?
Am I doing something the hard way or ...
9
votes
4answers
289 views
Pointer version of strcat
Write a pointer version of the function strcat that we showed in Chapter 2: strcat(s, t) copies the string t to the end of s.
This is the version of strcat from Chapter 2:
void strcat(char s[], ...
11
votes
3answers
639 views
Simple Java calculator
I am a beginner in Java programming. Here is my simple calculator. I hope you could scan through my coding and let me know if there is any error in my coding or how I could simplify the code.
import ...
-1
votes
0answers
15 views
Change class for date in datepicker directive that is always visible [migrated]
I am new to angularJs and jQuery and have this problem I am trying to solve. I created a datepicker directive that is always visible. I have a list of changing dates, that I want to use to update the ...
7
votes
2answers
240 views
Game with tile map - Sprite-Kit
I'm a novice programmer learning Objective-C in my spare time. I would greatly appreciate any help or advice with my code. I want to follow best practices whenever possible. I know that I am ...
7
votes
2answers
125 views
Matching program in Java
I am new to Java and wrote one small program. It works fine, but it looks like it doesn't meet OOP concepts. Could someone look and give me advice so that I can fine tune?
public class App {
...
6
votes
1answer
41 views
Pass in parameters instead of multiple functions
I can't quite figure out the best way to approach this. I have two jQuery objects that both are used to set cookies. I then parse the JSON and set a cookie that is either the users height or the users ...
1
vote
2answers
38 views
Managing while loop in bash
Two difference scenario in bash program,
First
Here i am breaking loop in function testFunc.
#!/bin/bash
function testFunc {
if [ some condition ] ; then
break
fi
}
while [ 1 ]
do
...
2
votes
2answers
70 views
Rational arithmetic calculator
My program is a fraction calculator that is supposed to calculate the basic operations (+, -, *, /) and is supposed to exit when I enter % as my sentinel value. This is what I have so far; any ...
10
votes
5answers
576 views
Minimal Game of Life in C#
I want to learn how to write clean code from the start. This is my first project, a 'Minimum Viable Product' implementation of Conway's Game of Life in C#. Mostly I want to know if my code is ...
5
votes
1answer
68 views
Read text from stream char by char
I've started learning F# and functional programming in general, but the code I wrote doesn't seems to be really functional. Could you take a look and say how to make it more as it should be in ...
7
votes
1answer
85 views
Find the word in a string that has the most repeated characters
The problem: I want to find the word in a string that has the most repeats of a single letter, each letter is independent. Does not need to be consecutive.
Currently I am jumping each character and ...