Search Results

Search: Posts Made By: totoro125
Forum: Programming 12-07-2014
5,850
Posted By ongoto
@ totoro125 You give me all kinds of ideas. :)...
@ totoro125
You give me all kinds of ideas. :)

You could have two classes and keep transactions separated.

Class CashRegister
An accounting of the bills/coins that should be in your drawer....
2,023
Posted By ongoto
First, make sure sort1 is executable. Then...
First, make sure sort1 is executable.

Then try $ time ./sort1 (full path to sort1)
Bash is not finding the new sort1 because it is not in your PATH.

Edit: Oops
Sorry Don Cragun. Didn't see...
2,023
Posted By Don Cragun
Is . in your setting of $PATH? If not, did you...
Is . in your setting of $PATH?
If not, did you try:
$ time ./sort1 < sort1.c > /dev/null
Forum: Programming 12-01-2014
5,850
Posted By sea
Eventhough BASH is my currently my most favorite...
Eventhough BASH is my currently my most favorite language, for (possibly) 'real' applications, specialy when it comes with numbers handling as in do math, i would choose something else... like...
Forum: Programming 12-01-2014
5,850
Posted By gandolf989
You might want to start with how do you make...
You might want to start with how do you make change. You can use a floor or truncate function with division to tell how much of a certain currency you will give as change. Subtract the value of that...
Forum: Programming 12-01-2014
5,850
Posted By rbatte1
I would use what you are most comfortable in, or...
I would use what you are most comfortable in, or even use this as practice for writing in them all. The key thing to get you logic documented so you can then write the code without having to think...
Forum: Programming 11-22-2014
2,394
Posted By Corona688
So you passed qsort the wrong comparison program...
So you passed qsort the wrong comparison program and it crashed?

This is natural enough. qsort takes blind, i.e. void types -- the compiler cannot not know what type you are passing into it. ...
Forum: Programming 11-13-2014
1,550
Posted By Corona688
It also can't handle escaped things like "this is...
It also can't handle escaped things like "this is a string with a \" mark inside it" But that may not be a bug if you don't consider that valid, since it isn't actually causing a crash.
...
Forum: Programming 11-13-2014
1,550
Posted By junior-helper
I'm no C programmer, but I think I know some...
I'm no C programmer, but I think I know some basics ;)

First of all, you'll need to compile this code, try
gcc csvgetline.c #produces executable file a.outor
gcc -o csvgetline csvgetline.c ...
Forum: Programming 11-09-2014
3,386
Posted By junior-helper
Looks like only one command is executed within...
Looks like only one command is executed within the for loop if you leave out the braces { and } in the for loop.

Either you use Don's first approach with braces, or you try this:
...
Forum: Programming 11-09-2014
6,018
Posted By junior-helper
Integer.parseInt has a funny side effect though....
Integer.parseInt has a funny side effect though. It will convert 000 to 0, 03 to 3 and so on.
import java.util.Date; // mandatory only for the "current date and time" part

public class prob4
{...
Forum: Programming 11-09-2014
3,386
Posted By Don Cragun
You seem to want something more like: int...
You seem to want something more like:
int i;
int n = 100;
for (i=0; i<n; i++) {
System.out.print(ArgumentFromCommandLine);
System.out.print(" ");
}
What you...
Forum: Programming 11-07-2014
3,386
Posted By junior-helper
This means the program's name is Hundred (source...
This means the program's name is Hundred (source file name Hundred.java) and Gertrude is the argument.

The first argument will be stored in args[0], thus you can simply put following in the for...
5,384
Posted By Aia
Let's do this: if you have another question,...
Let's do this: if you have another question, comment every line of this snippet with what you think is doing first.

#!/usr/bin/python

# This is an example intended as a guide only and not as a...
5,384
Posted By Aia
You need a more complex construct to do that, now...
You need a more complex construct to do that, now we need to split the line into tokens.

#!/usr/bin/python

f = open("file3", "r")
lines = f.readlines()
f.close()

for l in sorted(lines,...
2,321
Posted By Chubler_XL
I'm not entirely sure the code you posted was...
I'm not entirely sure the code you posted was python, their is no sys.argc and instead you would use len ( sys.argv ), however if we forget about the main function definition you can get some output...
2,321
Posted By Chubler_XL
entry* table[ TABLE_SIZE ] = { NULL }; this...
entry* table[ TABLE_SIZE ] = { NULL }; this statement initializes the "table" array as a TABLE_SIZE (7) element array with NULL pointers. In C arrays are indexed from zero so we end up with:
...
2,321
Posted By Chubler_XL
This is a simplified representation of how the...
This is a simplified representation of how the table array would look:

table[0] (Undefined)
table[1] (Undefined)
table[2] (Undefined)
table[3] => {"Bob", 38} -> {"Cos", 86}
table[4] =>...
2,321
Posted By Corona688
Your first program is incomplete, List and sNode...
Your first program is incomplete, List and sNode aren't defined anywhere, which is why it looks so weird. I can probably assume list and snode are the same, so they look like this:

typedef struct...
5,384
Posted By Aia
> Can I just add dict.sort to sort it numerically...
> Can I just add dict.sort to sort it numerically by id?
Yes, you can sort the keys of a dictionary. Nevertheless, you should use sorted(dict)

> And once I sort it, how do I print it out?
That...
5,384
Posted By Aia
f = open("food","r") l = f.readline() dict...
f = open("food","r")

l = f.readline()
dict = {}
while l:
l = l.split()
id, value = l[0], l[1:]
dict[id] = value
5,384
Posted By Aia
f = open("exams","r") # opens the file exams to...
f = open("exams","r") # opens the file exams to read

l = f.readline() # reads the first line
while l: # loop while there's a line
l = l.split(" ") # split the line into an array
values...
1,222
Posted By Aia
Just like that. the flag -r in grep tells it to...
Just like that. the flag -r in grep tells it to do recursive.
1,518
Posted By Aia
Does this do what you want? ls *_* | sort -t_...
Does this do what you want?
ls *_* | sort -t_ -k2 -g

The error is due to the test, it should be:

if [ -f "$i" ]; then It is required to have spaces after and before `[ and ]'.

----------...
903
Posted By Aia
There is a command named `find' which will do...
There is a command named `find' which will do that for you

find /path/to/directory -name "*_*" -type f
That could display every file that contain an `_' in /path/to/directory and below.
Showing results 1 to 25 of 25

 
All times are GMT -4. The time now is 10:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy